我遇到一个问题,当我尝试创建一个文件夹时,它会创建一个文件。具体来说,它发生在变量文件夹中。代码如下,我正在使用python 2.7
import os
i = False
while i != True:
fil = raw_input("Enter Filename Here: ")
i = os.path.exists(fil)
if i == False: print("File does not exist! Try Again.")
folder = raw_input("Enter Output Folder Here: ")
try:
os.path.exists(folder)
except:
if not os.path.exists(folder):
print("Creating Folder for You.")
os.makedirs(folder)
output = raw_input("Enter Chlorophyll-a Output Filename Here: ")
full = os.path.join(folder,output)
if os.path.exists(full):
yesno = raw_input("Output file already exists are you sure you want to overwrite? Yes/No: ")
if yesno == "Yes":
k = open(full,"w")
if yesno == "No":
raise SystemExit("Exiting File Now!")
if not os.path.exists(full):
print ("File Does Not Exist. I Will Make It For You.")
k = open(full,"w")
在我的计算机上,我收到此错误
Traceback (most recent call last):
File "C:/Users/---/.PyCharmCE2019.2/config/scratches/scratch_6.py",line 33,in <module>
k = open(full,"w")
IOError: [Errno 2] No such file or directory
我在做什么错?我似乎无法弄清楚