如何改变INI配置文件中的SECTION NAME
1个回答
展开全部
def func():
input = open(r"c:\test.ini")
lines = input.readlines()
input.close()
output = open(r"c:\newest.ini",'w');
for line in lines:
if not line:
break
if 'name' in line:
temp = line.split("name")
temp1 = temp[0] +'myname'+ temp[1]
output.write(temp1)
else:
output.write(line)
output.close()
if __name__ == '__main__':
func()
input = open(r"c:\test.ini")
lines = input.readlines()
input.close()
output = open(r"c:\newest.ini",'w');
for line in lines:
if not line:
break
if 'name' in line:
temp = line.split("name")
temp1 = temp[0] +'myname'+ temp[1]
output.write(temp1)
else:
output.write(line)
output.close()
if __name__ == '__main__':
func()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询