输入
用print()
,括号中为输出内容,代码实现如下:
>>>print('hello world')
hello world
>>>print('A','B','C')
A B C
>>>print('100+200='100+200)
100+200=300
输出
用input()
,可以输入字符,并放在一个变量里,代码实现如下:
>>>name=input()
Alice
>>>name
Alice
>>>print(name)
Alice
input()
括号中可以写入提示信息,代码如下:
name=input('please enter your name:')
print('hello', name)
此时运行结果会得到:
C:\Users\fr>python hello.py
Alice
hello Alice