输入:
>>> print('hello,world')
hello,world
>>> print('Genius is 1%','inspiration and','99% sweat')
Genius is 1% inspiration and 99% sweat
>>> print(300)
300
>>> print(100+200)
300
>>> print('100 + 200 =',100+200)
100 + 200 = 300
输出:
>>> name = input()
Michael
>>> name
'Michael'
>>> print(name)
Michael
文本编辑hello.py:
name = input()
print('hello,', name)
D:\Pythoncode>python hello.py
Michael
hello, Michael
文本编辑hello.py:
name = input('please enter your name:')
print('hello,', name)
D:\Pythoncode>python hello.py
please enter your name:Michael
hello, Michael
练习:
>>> print('1024 * 768 =',1024*768)
1024 * 768 = 786432
注:多个字符串间的逗号,输出时显示为一个空格