First write Python, write Python
#! /Usr/bin/env python (specify the interpreter used to run the script and where the interpreter is located) #-*-coding: UTF-8-*-(used to specify the file encoded as UTF-8) # Invalid Content, only used for comments (Single line comment) "Aidfjoisjfijw """(Multi-line comment)[Username and password applet]
I1 = raw_input ("Enter the User name:") # raw_input is used to interact with the user, waiting for the user to enter the content (I am using python 3.5.2, raw_input () when executing this program () an error is reported, but it can run normally after it is changed to input (). It is probably only supported by python 2.7.) i2 = raw_input ("enter the password :") print (i1) print (i2)
- Getpass ModuleA portable password is provided, which includes the following two functions:
1. getpass. getpass ()
2. getpass. getuser ()
Getpass. getpass ([prompt [, stream])
Prompt the user to enter a password, parameterPromptIt is used to prompt the user to start inputting. The default value is 'password :'. On Unix, the prompt is written to the class file object stream. The default value of the parameter stream is the control terminal (/dev/tty) or sys. stderr when the former is unavailable (this parameter is invalid on Windows ).
If no echo input is unavailable, getpass () is rolled back to the stream.StreamOutput a warning message, read from sys. stdin and throw an exceptionGetPassWarning.
Applicable to: Macintosh, Unix, and Windows.
* Note:
If you call getpass () in IDLE, the input may be completed in the terminal where you start IDLE instead of in the IDLE window.
Improt getpasspwd = getpass. getpass ("enter the password:") # The password entered by the user is invisible.
【Username and passwordSmall Program Improvement]
Import getpassi1 = raw_input ("UserName:") i2 = getpass. getpass ("PassWord:") # invisible PassWord print (i1) print (i2)