input(prompt=None, /)
Read a string from standard input. The trailing newline is stripped.
The prompt string, if given, is printed to standard output without a
trailing newline before reading input.
If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.
On *nix systems, readline is used if available.
私以为input接受的所有参数都是以字符串的形式保存的。
print("How old are you?",end='')
age=input()
#简写如下
height=input("How tall are you? ")#引号内为提示语句
print("how many trees now?")
x=int(input())#必要时转换字符格式
argv是sys库中的一个函数,用于在命令行直接输入参数,而input可以在程序运行中交互输入。
from sys import argv
# read the WYSS section for how to run this
script, first, second, third, = argv
print("the script is called:",script)
print("your first variable is:",first)
print("your second variable is:",second)
print("your third variable is:",third)
命令行(power shell)
PS C:\Users\Administrator\temp> python ex10.py 1 2 3 the script is called: ex10.py
your first variable is: 1
your second variable is: 2
your third variable is: 3