1.Module initialization
1) Getpass Module
Program Examples:
Import Getpass
_password= ' Penny '
_password= ' abc123 '
Passname=input (passname:)
Password=getpass.getpass ("Password:")
If Passname=_passname and Password=_password:
Print ("Welcome {name} loding ...". Format (Name=passname))
Else
Print ("Invarild Pass name or pass word")
Python's own IDE terminal does not support the hidden echo, to use the system's terminal, such as the word cmd under Windows.
Ps:
CMD location: C:\Windows\System32\cmd.exe
You can use the shortcut key: Win logo key +r, directly in the run bar input cmd, the carriage return can be run.
2) SYS module
Program examples
Import Sys
Print (Sys.path) #打印路径与环境变量
Print (SYS.ARGV)
3) OS Module
Program examples
Import OS
Os.system ("dir")
Com_red=os.system ("dir")
Print ("--->", com_red) # Executes the system command only, executes successfully returns 0, does not save the result
Program examples
Import OS
Com_red=os.popen ("dir") #将命令临时存放在一个地址里面
Com_red=os.popen ("dir"). Read () # reads it out with read
Print ("--->", com_red)
Program examples
Import OS
Os.mkdir ("New_dir") # Create a new module
4) Write your own third-party module and reference it
The module you write can be placed under the lib\site-packages\ path of the default file, or you can choose to place it in another location, and then set the path to the environment variable, with import reference;
Learning notes for Python/002-1 (2018-5-18)