Unsupported operation :not writeable python

后端 未结 2 859
孤独总比滥情好
孤独总比滥情好 2020-12-05 23:01

Email validation

#Email validator
import re


def is_email():
    email=input(\"Enter your email\")
    pattern = \'[\\.\\w]{1,}[@]\\w+[.]\\w+\'
    file = o         


        
相关标签:
2条回答
  • 2020-12-05 23:35
    file = open('ValidEmails.txt','wb')
    file.write(email.encode('utf-8', 'ignore'))
    

    This is solve your encode error also.

    0 讨论(0)
  • 2020-12-05 23:41

    You open the variable "file" as a read only then attempt to write to it:

    file = open('ValidEmails.txt','r')
    

    Instead, use the 'w' flag.

    file = open('ValidEmails.txt','w')
    ...
    file.write(email)
    
    0 讨论(0)
提交回复
热议问题