簡體   English   中英

將JSON數據寫入python中的文件

[英]Writing JSON data to file in python

我不太確定如何編寫JSON所以請您幫我,我正在嘗試使用python JSON實現此功能。 這是偽代碼

binary_students = json(students)

write_to_the_file_system(binary_students)

我不太了解,有人可以幫我嗎。

您可以使用字典來存儲Json數據,如下所示:

>>> dict = {'Student1':'x1','Student2':'x2'}

然后使用json

>>> import json
>>> with open('data.txt', 'w') as outfile:
    json.dump(dict,outfile)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM