First write Python, write Python

Source: Internet
Author: User

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)

 

 

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.