import re
import sys
path = "E:/SvnProjects/xxx/xxx/template/web/index.html"
#修改index.html文件,设置网络类型
def updatefiles(netModel):
f = open(path,'r')
alllines=f.readlines()
f.close()
ff = open(path,'w')
for line in alllines:
if re.search('var ServerNetType = 0;', line):
if netModel == 0:
ff.write(line)
else:
ff.write('var ServerNetType = 1;\n')
elif re.search('var ServerNetType = 1;', line):
if netModel == 1:
ff.write(line)
else:
ff.write('var ServerNetType = 0;\n')
else:
#print(line)
ff.write(line)
ff.close()
def openFile(netModelId):
print('netModelId', netModelId)
if netModelId == '0':
print('内网修改中...')
updatefiles(0)
elif netModelId == '1':
print('内网修改中...')
updatefiles(1)
else:
print
python 根据输入,修改文件里面内容
最新推荐文章于 2022-12-12 17:29:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)