1. Definition:
modules: Used to logically organize Python code (variables, functions, classes, logic: Implementing a function), which is essentially a Python file at the end of the. Py.
package: Used to logically organize the module, essentially a directory (must have a file called __init__.py)
2. How to import
Import Module:
Import Module1,module2
From Module1 Import *
From Module1 Import logger (module) as Logger2 (alias)
Importing Packages: Import
3.import Nature (Path search and search path)
Import module: Explain the Python file again
Import Package: Execute the init.py file under the package
4. Import Optimization
From module_test Import test
5. Module Classification
A. Standard library
B. Open source module
c. Custom Modules
Standard library:
1.time with datetime timestamp, formatted time output, tuple
Time :
TimeZone (UTC to seconds), Altzone (UTC and DST to seconds), daylight (whether DST is used)
functions:
time () timestamp time.time ()
clock ()
sleep () delay
gmtime () Seconds to () UTC
localtime () seconds to () local
asctime () tuple to string%a (week)%b (month)%d (day)%H%M%s%Y (year)
CTime () timestamp seconds converted to the above format
mktime () Local to seconds
strftime () tuple to String strftime (format,tuple)
strptime () string to tuple Strptime (String,format)
Tzset ()
2.random Module
3.OS Module
4.sys Module
5.shutil Module Advanced file, folder, compression package processing module
6.json, pickle module
7.shelve Module Pickle
8.xml Processing module implements the protocol for data exchange between different languages or programs
9.ConfigParser module for generating and modifying common configuration documents
10.hashlib module for encryption-related operations
Python Basics-Module Learning