#思路:将原文件里的内容读取,然后通过下标修改内容,二次覆盖写入 user="lm" def update_other_file_name(file,index,new_name): import time t=[] with open(file, 'r')as f1: text = f1.readlines() text[index]='user="%s"\n'%new_name time.sleep(3) for line in text: t.append(line) with open(file, 'w')as f: for l in t: f.write(l) file="/Users/lm/Desktop/self_test/appium_script/app/__init__.py" new_name='zs' update_other_file_name(file,0,new_name)
修改其他文件中的变量
猜你喜欢
转载自blog.csdn.net/liming066/article/details/84982933
今日推荐
周排行