[英]How to export and import a variable amount to a json file to keep numbers after program ends
This Problem has been solved.这个问题已经解决了。
I have googled this many times, but can't seem to find out how to export a variable's data to a JSON file.我已经用谷歌搜索了很多次,但似乎无法找到如何将变量的数据导出到 JSON 文件。 I also am having problems importing them back and would like it if someone could point me to an article that would explain how to make the code that I have work.
我在将它们导入回来时也遇到了问题,如果有人可以向我指出一篇解释如何使我拥有的代码工作的文章,我会很高兴。 Here is the code:
这是代码:
bank_data={
'name1': name1,
'name2': name2,
'name3': name3,
'p1bal': p1bal,
'p2bal': p2bal,
'p3bal': p3bal,
'namenumb': namenumb,
'namepass1': namepass1,
'namepass2': namepass2,
'namepass3': namepass3,
}
json_string=json.dumps(bank_data)
with open('bank_files.json', 'w') as outfile:
outfile.write(json_string)
if you would like to view the full program to see how this is being used, here is the link: https://app.codingrooms.com/w/13hXi2nKIEZf如果您想查看完整程序以了解其使用方式,请点击以下链接: https://app.codingrooms.com/w/13hXi2nKIEZf
Thanks!谢谢! -TenseSnake9
-TenseSnake9
I have answered my own question.我已经回答了我自己的问题。 Thanks to everyone who helped.
感谢所有帮助过的人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.