目录
一、输出类型
1.数字
print(520)
print(98.5)
运行截图
2.字符串
print('helloworld')
print("helloworld")
运行截图
3.含运算符的表达式
print(3 + 1)
print(2 * 3)
运行截图
二、换行问题
1.换行输出
print('world')
print('hello')
print('python')
运行截图
2.不换行输出
print('world', 'hello', 'pyhton')
运行截图
三、输出到文件中
注意点:
- open() 所指定的盘符要存在
- print() 内使用 file =
ex = open('F:/python/mystudy/test.text', 'a+') # a+如果文件不存在就创建,如果存在就在已有内容后继续添加
print('helloworld', file=ex)
ex.close()
运行后自动新建了一个文件
Flag:我要成为一个日更选手:)