txt转json python

txt到json的核心代码是:

f=open(p,mode="r",encoding="utf-8")
data=f.read().replace(" ","").replace("\n","")
filejson[fn.rstrip(".txt")]=data
f.close()
              lcb8816
          Python