windows 默认换行符为 \r\n; unix默认换行符为 \n; 所以当win下编辑的脚本在linux下显示末尾多了^M: 换行符修改为同一的unix格式脚本如下: def run(path,file): for file in files: file = path+'\\'+file f = open(file,'r') result = f.read() print result result = result.replace(r'\r\n',r'\n') f.close() # 需要…