您好,登錄后才能下訂單哦!
configfileLine = ''
old = ['20003','10003','s3','zxjRYZGI','sid','2018','=5','=19']
new=[clientPort,httpPort,dbName,password,SvrId,openYear,openMonth,openDay]
for old,new in zip(old,new):
with open(deploy.servicedir + str(i) + '/Config.lua','r')as f:
for line in f.readlines():
if line.find(str(old)):
line = re.sub(str(old),str(new),line)
configfileLine += line
else:
configfileLine += line
with open(deploy.servicedir + str(i) + '/Config.lua', 'w')as f:
f.write(configfileLine)
configfileLine = ''
只修改一個配置文件,configfileLine等于空,讀該配置文件覆蓋寫入,再清空,修改第二項,再重新覆蓋寫入配置文件
start_stop_Line = ''
for scriptName in ['start.sh','stop.sh']:
with open(self.servicedir + str(i) + '/bin/' + scriptName, 'r')as f:
for line in f.readlines():
if line.find('1'):
line = re.sub('1', str(i), line)
start_stop_Line += line
else:
start_stop_Line += line
with open(self.servicedir + str(i) + '/bin/' + scriptName, 'w')as f:
f.write(start_stop_Line)
start_stop_Line = ''
修改兩個配置文件,清寧德start_stop_line寫入第一個配置文件,再清空,再寫入第二個配置文件
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。