matcher = re.compile(r"hklay1\s+(.*?)\s+kppt1", re.DOTALL)
for i in xrange(1, 5):
with open("data{}.txt".format(i), "r") as f:
with open("nwirp{}.upw".format(i), "r") as f2:
with open("data{}.upw".format(i), "w") as out:
content = matcher.findall(f.read())
print content
for line in f2:
lines = line.replace('5.0472640E-03', 'content')
out.write("".join(lines))
写入文件中的内容应该是数字,但内容变成这样的内容
9-8.8880000000E+003 0#数据集1,IUPWCB HDRY NPUPW IPHDRY
10#铺设类型
10层平均值
-1-1#通道
1 1#拉伊夫卡
0 0#湿铺
内部1.0(免费)12#HK第1层第1层
内容
内容
内容
内容
内容
内容
内容
内容
内容
内容
内容
内容
内容
谁能告诉我这里有什么问题吗?你知道吗
在
lines.replace(...)
中围绕'content'
的引号。你知道吗相关问题 更多 >
编程相关推荐