请教下 f = f.replace('\n', '\r')这条没起作用
!/usr/bin/env python
-- coding: utf-8 --
import json
import string
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
def readfile(f):
with open(f, 'r') as f:
return f.readlines()
f = f.replace('\n', '\r')
def main():
f = sys.argv[1]
debugfile = readfile(f)
for i in debugfile:
print json.dumps(eval(i),sort_keys=True, indent=2, ensure_ascii=False, encoding='utf8')
if name == 'main':
main()
勤學如春起之苗,不見其增,日有所長。綴學如磨刀之石,不見其損,日有所虧。