Python module-Day8

Source: Internet
Author: User

1, using the module reason

To save memory

2, what is the module

    • Python code or C language code
    • Sort by function

3. Module classification

    • Built-in modules, modules included in the Python interpreter
    • Expansion module, installation required
Import Time forIinchRange (0,101,2): Time.sleep (0.1) Char_num= I//2#print How many ' * 'Per_str ='\r%s%%:%s\n'% (I,'*'* Char_num)ifi = = 100Else '\r%s%%:%s'% (I,'*'*char_num)Print(per_str,end="', flush=true)
Print progress bar

4. Built-in module

    • Collections  :   Extended Database type
Import= collections.namedtuple ('tuples', ['a' ,'b','C'= t (  Wang', a)print(mytup)
View Code
Results:
Tuples (a=24, b= ' Wang ', c=80)
Specify a key first, which is equivalent to defining a class;
Specifying value again is the equivalent of instantiating this class;
  • Deque is a two-way list for efficient insert and delete operations, suitable for use in queues and stacks
     fromCollectionsImportDequeq= Deque (['a','b','C']) Q.append ('x') Q.appendleft ('y') Qdeque (['y','a','b','C','x'])
    View Code

Python module-Day8

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.