所以我想在程序运行时创建一个文件夹,因为在我创建它之后,我需要放入一些文件。
我意识到它不会立即创建,也想问为什么会发生这种情况。
我也收到此错误
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\NemPl\\Desktop\\ProLan\\Python\\Python programi\\user.NemPlayer\\pass.asd123ASD'
编辑:
以下是源代码,它不会立即显示我的文件夹:
import re
import urllib.request
import os.path
print("------PROFILE CREATOR------")
print()
while True:
breakLoop = 0
notCorrect = ""
correct = 0
profileName = input("Username: ")
if profileName == "":
print("Your username can't be blank!")
continue
elif os.path.isdir("user." + profileName):
print("Username taken!")
continue
else:
pass
for n in profileName:
if re.search(r" ", profileName):
notCorrect += "...can't contain spaces!\n"
if notCorrect == "":
breakLoop = 1
break
else:
print("Your username...")
print(notCorrect)
break
if breakLoop == 1:
os.makedirs(r'C:\Users\NemPl\Desktop\ProLan\Python\Python programi\user.' + profileName)
break
else:
pass
while True:
notCorrect = ""
breakLoop = 0
profilePassword = input("Password: ")
if profilePassword == "":
print("Your password can't be blank!")
continue
else:
pass
for n in profilePassword:
if re.search(r' ', profilePassword):
notCorrect += "...can't contain spaces!\n"
if not re.search(r'\d', profilePassword):
notCorrect += "...has to contain at least one number!\n"
if not re.search(r'[a-z]', profilePassword):
notCorrect += "...has to contain at least one lowercase letter!\n"
if not re.search(r'[A-Z]', profilePassword):
notCorrect += "...has to contain at least one uppercase letter!\n"
if notCorrect == "":
breakLoop = 1
break
else:
print("Your password...")
print(notCorrect)
break
if breakLoop == 1:
filePassword = open(r"C:\Users\NemPl\Desktop\ProLan\Python\Python programi\user." + profileName + "\pass." + profilePassword)
break
else:
pass
答案 0 :(得分:1)
它是“没有这样的文件或目录”错误的“无此文件”方面。您需要包含“w”写入模式才能创建文件。
$key = array_search('525359',$array);
echo 'key is',$key;