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