python print()函数的使用:
- print()函数输出的内容可以是数字
- print()函数输出的内容可以是字符串
- print()函数输出的内容可以是含有运算符的表达式
print(520)
print(98.2)
print('hello world')
print("hello world")
print(3+1) : 3 和 1 称作操作数 ,+ 是运算符
-
print()函数可以将内容输出的目的地
- 显示器
- 文件
#将数据输出到文件中
#注意点:1.所指定的盘符要存在 2.使用file=
fp=open('D:/text.txt','a+') # ’a’追加写模式,’a+'追加读写模式
print('helloworld',file=fp)
fp.close()
#不进行换行输出(输出内容在一行当中)
print('hello','world','python')
输出: hello world python
-
print()函数的输出形式
- 换行
- 不换行