请教下 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()

posted @ 2017-02-20 16:46  easymoneySniper  阅读(816)  评论(0编辑  收藏  举报