json.dumps中indent参数是设置json缩进量的

举例:

tmp = {
"aaa" : "111",
"bbb" : '222'
}
import json

with open("tmp.txt", "w") as fp:
fp.write(json.dumps(tmp,indent=4))


打开tmp.txt查看效果

python实现将json数据以json格式写入txt文件

 


 
                    
            
                

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2021-09-09
  • 2021-12-06
  • 2022-12-23
猜你喜欢
  • 2021-09-16
  • 2023-01-28
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案