python 这个stdin怎么写

!/usr/bin/env python

-- coding: utf-8 --

import json
import pprint

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

def readfile(f):
with open(f, 'r') as f:
return f.readlines()

def main():

filelist = [
		"C:\Users\T_back\Desktop\debug.txt",
		"C:\Users\T_back\Desktop\pp.txt"
	]

for f in filelist:
	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()

file_name 是个字符串吧, for循环遍历字符串 你拿到的是字母 把for循环去掉

posted @ 2017-02-20 11:23  easymoneySniper  阅读(738)  评论(0编辑  收藏  举报