天天看点

Python输入输出

1        第一个Python

[root@daidai python]# cat calc.py

print(100+200+300)

[root@daidai python]# python calc.py

600

[root@daidai python]# cat hello.py

print('hello,world')

[root@daidai python]# python hello.py

hello,world

#!/usr/bin/python

[root@daidai python]# chmod +x hello.py

[root@daidai python]# ./hello.py

1.1   输出

>>> print('hello,world')

>>> print('hello,','world')

hello, world

print()会依次打印每个字符串,遇到逗号“,”会输出一个空格

>>> print('100+200=',100+200)

100+200= 300

1.2   输入

>>> name=input()

daidai

>>> name

'daidai'

>>> print(name)

>>> print('hello,',name)

hello, daidai

>>> name=input('Pleaseinput your name: ')  --input函数允许用户输入提示信息

Please input your name: daidai

上一篇: java输入输出
下一篇: CSV输入输出