读取文件内容
读取目录下所有文件的内容
import sys
import os
filepath = "post"
fp = open(outputfile, 'w')
pathDir = os.listdir(filepath)
for filename in pathDir:
tmpdata = {}
thisfile = filepath + '/' + filename
postid = filename.split('.')[0]
print(postid + ":")
fp.write('%s%s' % (postid, ":\n"))
#读取文件内容
content = open(thisfile, 'rb').read().upper()
#或者按照行读取内容map.txt文件
for l in open('map.txt', 'rb').readlines():
k = l.strip('\n')
kdata = k.split(' ')
print(kdata[0])