pyday10&11&12-Common modules: time|datetime|os|sys|pickle|json|xml, string formatting, py auto Global variables

Source: Internet
Author: User

1. py file automatically created global variables

Print (VARs ()) return value: {' __name__ ': ' __main__ ', ' __package__ ': None, ' __loader__ ': <_frozen_importlib_external. Sourcefileloader object at 0x0000025471756e10>, ' __cached__ ': None, ' __doc__ ': None, ' __file__ ': ' c:/users/john/ pycharmprojects/q1/day12/index.py ', ' __spec__ ': None, ' __builtins__ ': <module ' builtins ' (built-in);}

1.1 Common variables:

__doc__ #py文件的注释
__file__# own path
__package__# the package where the current. PY is located
__cached __#py Cache
__name__# display the name of the py file;

1.2 Infrequently used variables:

__LOADER__: System call
__spec__ system Call
__builtins__# #存放内置函数

2. Module

For a complex function, multiple functions may be required to complete (functions can also be in different. py files), and the Code collection consisting of N. py files is called a module.

Like functional programming and process-oriented programming, functional programming accomplishes a function, and other code is used to invoke it, providing reusability of code and coupling between the code.

Modules can be divided into three types:

    • Custom modules:
    • Third-party modules:
    • Built-in modules: Call directly

3.

4. End

pyday10&11&12-Common modules: time|datetime|os|sys|pickle|json|xml, string formatting, py auto Global variables

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.