-2
我正在尝试在True循环中执行一系列检查以查看文件夹是否存在或用户错误。在我的文件夹中,我有两个文件夹A和B.我将要求用户输入文件夹名称。检查用户在Python中输入的文件夹是否存在
from os.path import exists
folder1_2 = input('Enter folder name: ')
i = (folder1, folder2)
while True:
i = raw_input()
does_it_exist = os.path.exists(i) # True/False
if does_it_exist == False:
print("The folder does not exist")
continue
if os.listdir(".") == False:
print("folder not found")
continue
if i('A', 'B') == False:
print("not the same folder or user error")
continue
break
print("All tests passed successfully!")
return [folder1_2]
您似乎忘记提问了。除了缩进之外,这段代码有什么问题? –
'os.listdir(“。”)== False'几乎没有用......'os.listdir'返回一个列表,所以它不会'False' –
也'如果我('A','B') ==假:“是错的。 '我'是一个字符串,而不是一个函数。请阅读有关python的更多信息。 –