Update getdata.py

master
p2tfsuw8f 3 years ago
parent fcfa3da2e4
commit 533acef68b

@ -21,4 +21,13 @@ def openreadtxt(file_name):
tmp_list[-1] = tmp_list[-1].replace('\n', '') # 去掉换行符
data.append(tmp_list) # 将每行数据插入data中
file.close()
return data
return data
def updateFile(file, old_str, new_str):
with open(file, "r", encoding="utf-8") as f1, open("%s.bak" % file, "w", encoding="utf-8") as f2:
for line in f1:
f2.write(re.sub(old_str, new_str, line))
os.remove(file)
os.rename("%s.bak" % file, file)
f2.close()
f1.close()
Loading…
Cancel
Save