Python Tiger flutter registration check script

Source: Internet
Author: User

Ulipad, looking very comfortable.

The code in the diagram is the result of this evening.

All of a sudden I wanted to see Python, a language that many people say is elegant, so that at night it's all about matching the environment and doing something

1 #Encoding:utf-82 ImportUrllib3 ImportUrllib24 5 #Name: Names to register6 #determine if name is available7 deftestusername (name):8Url="http://passport.hupu.com/index.php"9params={'m':'User','a':'Isusername','username': Name}Tendata1=Urllib.urlencode (params) Onereq=Urllib2. Request (URL,DATA1) AResponse=Urllib2.urlopen (req) -res=Response.read () -Status=eval (RES) ['Code'] the     ifstatus=='1': -         returnTrue -     returnFalse -  + #path: File name - #read the name in the file and return the unregistered name in the file + defshowuseablename (path): A      atList_name=[] -file=Open (Path) -      forLineinchFile: -Line=line.strip ('\ n') -Line=line.decode ('GBK'). Encode ('UTF8') -         ifTestusername (line): in List_name.append (line) -     returnList_name to  +  -Items=showuseablename ('List.txt') the  forIteminchItems: *     PrintItem.decode ('UTF8'). Encode ('GBK') $Raw_input ()

The user name in the List.txt will be read to detect registration, if not registered, it will be displayed.

Python is graceful and not graceful, but it's pretty comfortable.

Python Tiger flutter registration check script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.