Python user input

Source: Internet
Author: User

User input

python2.0

name = Raw_input ("input your Name:")   

#raw_input the input received is a string and a number, and Python is considered a string.

#input input receives numbers and characters ,

#input Python thinks the input number is a number, and the input character is a variable.

    python3.0

name = input (" Input your name: ")     

#输入接收的是字符串和数字, Python is considered a string.

name = int (input (" Input your age: ")  

#用int () forces the input string to be converted to int, accepting only the number

input Password not visible

#!/usr/bin/env python #指定解释器

#-*-coding:utf-8-*-#编码支持中文

import getpass                        #导入getpass模块

pwd = getpass.getpass("请输入密码:")                  

# assigns the user entered password to the PWD variable, the password is not seen

print(pwd)                            # Print What you have entered



This article is from the "506554897" blog, please be sure to keep this source http://506554897.blog.51cto.com/2823970/1906372

Python user 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.