Python Note 3-output input

Source: Internet
Author: User

Input, output

How does python receive user input, use the input function, use Raw_input in Python2, receive a string, output, the first program has been written using print, code into the following:

1

2

Name=input (' Please enter your name: ') #把接收到的值赋给name变量

Print (name) #输出接收到的输入

Input at the time of receiving inputs, you can see the value you entered, if you enter a password like this, do not want to let others see your password, how to do it, you need to use a standard library, Getpass, what is the standard library, is not need you to install, loaded Python on the library, is the standard library, Getpass is a standard library, import in, directly using the Getpass.getpass method can be entered at the time, do not echo, the code is as follows:

1

2

3

Import Getpass #导入getpass模块

Password = getpass.getpass (' Please enter your password: ') #接收输入的密码

Print (password)

# Input/Output
# name=input ('
Please enter your name: ') # Enter username
# print (name)
#
Enter the password, the password is not visible
Import getpass # Importing a module
passwd=getpass.getpass (" Please enter your password")
Print (passwd)# Note: Getpass cannot be executed in Pytcharm

Python Note 3-output input

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.