Emailhoạt động được hỗ trợ: không ghi được python
#Email validator
import re
f= open ('ValidEmails.txt', 'w')
def is_email():
email=input("Enter your email")
pattern = '[\.\w]{1,}[@]\w+[.]\w+'
file = open('ValidEmails.txt','r')
if re.match(pattern, email):
file.write(email)
file.close
print("Valid Email")
else:
print("Invalid Email")
#The Menu
print("The Email validator progam \n")
print("What do you want to do\n")
print("Validate the Email")
print("Quit")
while True:
answer=(input("Press V, or Q : "))
if answer in("V" ,"v"):
is_email()
elif answer in("Q" ,"q"):
break
else:
print("Invalid response")
Tôi tự hỏi tại sao dữ liệu của tôi sẽ không viết thư cho disk.Python nói rằng hoạt động của tôi không được hỗ trợ.
is_email
file.write(email)
io.UnsupportedOperation: not writable
Tôi có nên chuyển đổi email thành một chuỗi như thế này hay
file.write(str(email))
là nó cái gì khác
Tôi có thể bị thiếu một cái gì đó rất đơn giản.
Vui lòng bao gồm cả truy xuất đầy đủ lỗi mà bạn thấy. –