Learning notes for Python/002-1 (2018-5-18)

Source: Internet
Author: User

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)

Related Article

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.