输出
用print()在括号中加上字符串,就可以向屏幕上输出指定的文字。print函数可以给多个参数,可以同时输出多个变量。
>>> print('hello, world')
打印数值型
>>> print(300)
300
>>> print(100 + 200)
300
打印多个参数
>>> print('100 + 200 =', 100 + 200)
100 + 200 = 300
输入
Python提供了一个input(),可以让用户输入字符串,并存放到一个变量里。
>>> name = input()
Michael
>>> name
'Michael'
>>> print(name)
Michael
name = input()
print('hello,', name)
name = input('please enter your name: ')
print('hello,', name)