=========================== Module ===========================
1.Python the py file is called a module.
2. The use of modules needs to be introduced, for example:
Import Sys
3. The import module needs to set the path.
>>> Import sys
>>> print (sys.path)
[', ' c:\\users\\administrator\\appdata\\local\\ Programs\\python\\python36-32\\lib\\idlelib ', ' c:\\users\\administrator\\appdata\\local\\programs\\python\\ Python36-32\\python36.zip ', ' c:\\users\\administrator\\appdata\\local\\programs\\python\\python36-32\\dlls ', ' C : \\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python36-32\\lib ', ' c:\\users\\administrator\\ Appdata\\local\\programs\\python\\python36-32 ', ' c:\\users\\administrator\\appdata\\local\\programs\\python\\ Python36-32\\lib\\site-packages ']
Sys.path is the directory that Python searches for when the module is imported. As you can see, the current directory is included.
This current directory is the directory that started the program. If you are using a shell. Should be the directory of the Shell's running files.
If you want to add a different directory, you can use append or extend added to the Sys.path.
4. If you start a Python program with a command line, you can pass in the parameter list.
ARGV is the abbreviation for the argument vector.
Parameter list saved in SYS.ARGV
I'm now testing it directly with my own idle, and like Visual Studio, you can set command-line arguments.
But can not find, Baidu said there is no this setting, command-line parameters are just a few pieces of text, you may fill in
SYS.ARGV =[sys.argv[0], ' argument1 ', ' argument2 ', ' argument2 '
After debugging the whole sentence add a # annotation off OK.
Typically, the first parameter is the default, and the absolute path of the program. You don't have to enter it yourself. The other input starts at the second position.
Or you can use CMD directly to start it.
5.from xxx.xx.x import xxxx
You can use the functions directly in the module without having to bother using the domain name again.
=========================== Bag ===========================
Package:
With the associated modules together, multiple modules within the package can be introduced simultaneously by introducing a package.
Under the package there are __init__.py files, a look will know that this is the inside of the package to use their own.
This file hints at Python, which is a package directory, not an ordinary directory. Specifies how files within the package are used.
Some editors will automatically generate this file. I remember using sublime as if it had not been generated, and then it will be automatically generated when it runs. Maybe the compiler will also generate it automatically.
When the package is imported, only the __init__.py is computed. If the file is blank, the module inside the package cannot be used. You also need to write the import statement inside this file.
After the Python code is compiled, the corresponding PYC file is generated. It should be an intermediate file.
Sys.modules can see the modules that have been loaded