錯誤提示:module' object has no attribute 'loads'

student = {‘name’:‘zhao’, ‘age’:‘18’ ,‘sex’:‘men’}
student1 = json.dumps(student)
print(student1) #此時轉換爲字符串類型

student2 = json.laods(student1)
print(student2) #此時轉換爲字典類型

json.dumps()用於將dict類型的數據轉成str
就記住了它把單引號的dict轉換成雙引號的str

json.loads()用於將str類型的數據轉成dict
它把單引號的str轉換成雙引號的dict

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章