"Python" socket programming constant Error problem-1 ' af_inet ' ERROR

Source: Internet
Author: User

123456789 # -*- coding: utf-8 -*- import  socket print   "Creating socket" =  socket.socket (socket.af_inet,  socket. SOCK_STREAM)   print   "done!"  print   "connecting to  Remote host " s.connect (( 80 )" print   "Done"

When Python uses the Socket.af_inet constant after using the import socket, this constant is not found in the module, it is strange to check the Internet, the Python import module will be imported according to the name of the file, My Python script file name happens to be socket.py, which causes the imported socket to be wrong, try not to make your own Python script and module the same name, and pay attention to the other file name and module name in the same folder conflict

This article is from the "SANR" blog, please be sure to keep this source

The above for my Baidu out of the results, and then I re-create a file to run the above code, or wrong, why?

That's right.... I did not delete the previous one, after the deletion of the normal ...

Remember not to use the module name after import to name the document ...

"Python" socket programming constant Error problem-1 ' af_inet ' ERROR

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.