How to learn Python, how to face so many standard libraries?

Source: Internet
Author: User

Reply content:

Python standard libraries are many, but not all of them are very cool.

Just one suggestion: if the Python standard library already has a class of modules in the set of operations, and some people on the Web recommend third-party libraries, don't think about it, use the latter. For example (Requests:http for humans ) to Urllib, such as (arrow:better dates and times for Python ) to DateTime. The use of these two libraries is not introduced, to take this opportunity to the Python standard library to spit a few sentences:

Under Python2, there was a Urllib standard library to handle the work of fetching some data from the network, but the library was too bad to use, such as a request to customize the request header in an HTTP protocol, but also to introduce another module httplib, too impersonal. So someone to it to do some expansion, packaging, called Urllib2, to add to the standard library, but this urllib2 still have a lot of places are not very useful, such as no connection pool this thing, do crawler that help people also have to tinker, then someone to it to do the expansion, packaging, called URLLIB3, Thankfully, this time I didn't join the standard library, but if the Python community is naming this new module for inclusion in the standard library is not so painful, I think URLLIB3 's existing functionality needs to be added to the standard library, and only one urllib is good. Fortunately, although the front said that good (requests:http for humans is also based on the expansion of URLLIB3, but the end of the digital tail of the naming nightmare, if you think of urllib4, feel a nausea.

or the name of the spit, this time to give a Python3 example, in Python3, Urllib and Urllib2 are merged together, called Urllib, according to the original two modules provided by the method of work scene classification, was put into Urllib.request, Urllib.parse, urllib.error three sub-modules, but the previously mentioned urllib3 like connection pooling such as useful, or is not supported. Looks better than Python2, let's take a look at the namespace of the Urllib.request module:
Urllib.Request.AbstractbasicauthhandlerUrllib.Request.AbstractdigestauthhandlerUrllib.Request.AbstracthttphandlerUrllib.Request.BasehandlerUrllib.Request.AddclosehookUrllib.Request.AddinfourlUrllib.Request.Build_openerUrllib.Request.getproxiesUrllib.Request.getproxies_environmentUrllib.Request.getproxies_macosx_sysconfUrllib.Request.parse_http_listUrllib.Request.parse_keqv_listUrllib.Request.Pathname2urlUrllib.Request.PosixpathUrllib.Request.to_bytesUrllib.Request.unquoteUrllib.Request.unquote_to_bytesUrllib.Request.UnwrapUrllib.Request.Url2pathnameUrllib.Request.UrlcleanupUrllib.Request.UrljoinUrllib.Request.Urlopen
Use so as to learn. =====2015-1-21 Update =======
Change the computer to give a good answer. Just beginning to learn the basic syntax of Python also some confused, do not know what to continue to learn something, so on the internet to see the Python challenge this game, is said to be 2007 to promote the python to get such a thing.
At that time, the first contact played two levels will not play down (then the coding ability and learning ability is really weak can)
This time again to find out to do, found that the real feeling is completely different, it will use one or two or even more Python standard library, he will give you some hints, and then you can follow the hint to Python's official website to see the use of the specific library, and then start to do. In this way, you can achieve a goal of understanding and learning the Python standard library. At least the next time you encounter a problem, you'll know what kind of Python library to solve.
Listen to the rain porch on my Blog | You is my convition, but there must is something wrong in my life I wrote the first 19 off the problem-solving report, we can refer to.
Here's a quick list of the libraries and Python knowledge you'll use:
No. 00 OFF: Digital computing.
No. 01 off: String
No. 02 off: Re or with the filter function can also
No. 03 off: RE
No. 04 off: Urllib
No. 05 off: Pickle
No. 06 off: ZipFile
No. 07 off: PIL
No. 08 off: bz2
No. 09 off: Turtle or PiL
10th: Find the Rules
11th off: PIL
12th off: File processing
13th off: Xmlrpclib
14th off: PIL
15th off: DateTime
16th off: PIL
17th off: urllib urllib2 cookielib xmlrpclib
18th off: Difflib binascii
19th off: Wave

Temporarily only to do here ... The back of the organic will continue to update ~

===== Original Answer =====
There is a Python challenge in the online game, a basic need to use one to two standard library, and then you can know the use of these libraries in practice. I've been doing this lately. Amway a bit of my blog, which has its own writing.
Listen to the Rain Xuan | You is my convition, but there must is something wrong in my life Which one to learn, more official documents. At this time to sacrifice my small project: https:// pypi.python.org/pypi/rd ir , Partner @ Rai
The recursive structure and documentation (PYDOC) of object within the Python module or module can be viewed in a tree-structured html, command line, and file format. Currently only support *nix Python 2.x,windows not tested, if you have Windows users can reflect the situation, sorry not windows.
At present, further in the planning iteration, welcome to try to make bricks and recommend the function. Report Issues:issues Lhfcws/rdir GitHub

example:rdir/test.py at Master Lhfcws/rdir GitHub

Download method: sudo pip install Rdir

================ advertising time is over, start answering questions. =======

1. How do I learn python?
I assume you have other relevant language bases. Find a primer like "Basic python tutorial" to see it again, download a Ipython (Windows is not the same as the idle can do it) interpreter familiar with the tutorial, and then write a small project such as multi-person chat room. You're going to be able to work your chatroom out, and you're already using Python to do simple parallelism, network communication, and all kinds of basic operations. It is recommended to use the LINUX/MACOSX system because the command line below you can write a little tool further to familiarize yourself with what library you need to search to see if there is one.
Learn to use PIP to do third-party module download management.

2. Learn the standard library
Without special study, you need what function to search people how to use, Python many library documents are not friendly. Maybe some implementations you do not know that there is a library, your own writing is very troublesome, but in fact it doesn't matter. You can get it out of the way. Then use it, wait until you know there is a better implementation or find the problem solved very troublesome feel to build the wheel, please search.


* The above answer is not suitable for more experienced programmers.
  • 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.