0
파이썬 문제가 있습니다.파이썬에서 텍스트 파일 추가시 문제가 발생했습니다.
사용자에게 전자 메일 주소를 묻는 프로그램을 만들었습니다. 몇 가지 검사를 한 후에 텍스트 파일에 추가합니다. 모든 것이 정상적으로 작동하지만 텍스트 파일에는 아무 것도 표시되지 않습니다. 오류가 표시됩니다.
내 코드는 다음과 같습니다
def main():
print("Hello and welcome to customer email program!")
count=0
while count < 1:
email=str(input("Email Address: "))
if "@" in email:
if email.islower == True:
count=2
with open("emails.txt", "a") as myfile:
myfile.write(email)
print("File added to databse")
else:
email=email.lower()
count=2
with open("emails.txt", "a") as myfile:
myfile.write(email)
else:
print("That is not an email address, please try again.")
main()
어떤 도움을 주시면 감사하겠습니다.
def main() :
print("Hello and welcome to customer email program!")
done = False
while not done :
email = str(input("What's your email address? "))
if "@" in email :
if not email.lower() == email :
email = email.lower()
done = True
f = open("emails.txt" "a")
f.write(email)
f.close()
else :
print("Please type in a valid email address, "+email+" isn't a valid email address")
main()
이 사용자의 요구에 맞게 수행합니다
1. 파일의 전체 경로를 사용해보십시오. 2.'email.islower :'할 수있다'== True '는 필요 없다. – alfasin
명확히하기 위해 프로그램은 "File added database"를 인쇄하지만, 완료되면 로컬 디렉토리에 "emails .txt "하지만 비어 있습니까? – tdelaney
가장 먼저 나타나는 것은 email.islower 대신 email.islower()를 작성하려는 것입니다. – matiasg