我的ipynb
文件中有密码作为变量。
如何在python的帮助下以编程方式更改新密码?
我已经尝试了以下方法,但是不起作用:
with open("file.ipynb", "r") as initial_file:
text = initial_file.read()
text.replace('passwordone', 'passwordtwo')
with open("file.ipynb", "w") as new_file:
new_file.write(text)
最佳答案
将文本变量分配给新值
with open("file.ipynb", "r") as initial_file:
text = initial_file.read()
text = text.replace('passwordone', 'passwordtwo')
with open("file.ipynb", "w") as new_file:
new_file.write(text)
关于python - 如何使用python更改ipynb文件中的文本,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53758297/