代码:
import os.path
lines="hiya"
Question_2=input("Do you want a numeric summary report for? Y/N:")#If you input Y it will generate a single .txt file with number summary
if Question_2 == 'Y' or 'y':
print("Q2-YES")
OutputFolder = input('Name:')
x = os.mkdir(OutputFolder)
save_path = r'C:\Users\Owner\{}'.format(x)
ReportName=input("Numeric Summary Report Name.txt:")#Name Your Report ".txt"
completeName = os.path.join(save_path, ReportName)
f=open(completeName,"w+")
f.write(lines)
f.close()
回溯:
FileNotFoundError Traceback (most recent call last)
<ipython-input-13-83f8db356fab> in <module>
10 ReportName=input("Numeric Summary Report Name.txt:")#Name Your Report ".txt"
11 completeName = os.path.join(save_path, ReportName)
---> 12 f=open(completeName,"w+")
13 f.write(lines)
14 f.close()
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Owner\\None\\testr.txt'
我试图将条件 .txt 文件写入目录中创建的文件夹,由于某种原因,该文件夹仅在我的 jupyter 笔记本中创建,而不是在所需的目录中,因此出现“目录未找到错误”。有谁知道我如何更改它在所需目录中创建文件夹的代码?先感谢您
素胚勾勒不出你
慕侠2389804
相关分类