我还是Python新手,我很难理解为什么我的py文件在运行它的.py文件时不会写入文本。但每当我在 pycharm 上运行它时,它总是有效。在写入文件时我也尝试了很多选项,但它仍然不会在文件中写入任何内容,除非我在 Pycharm 上运行它。我错过了什么吗?请需要帮助
这是 .py 文件,每当我运行这个文件时,我都会告诉它,什么也没有发生
path = 'wifipasswords.txt'
my_open = open(path, 'w+')
my_open.write(final_output)
print(final_output)
my_open.close()
//MY attempts
# with open("wifipasswords.txt", "w") as f:
# print(final_output, file=f)
# pathlib.Path("wifipasswords.txt").write_text(final_output)
# with open("wifipasswords.txt", "w") as f:
# f.write(final_output)
# file = open("wifipasswords.txt", "w")
# file.write(final_output)
# file.close()
眼眸繁星
慕婉清6462132