print函数

print函数

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2022/5/7 14:16
# @Author  : Xiang
# @Site    : 
# @File    : print函数.py
# @Software: PyCharm
# 输出字符串
print("cctv")
print('hello world')
# 输出数字
print(520)
print(520.123212)
# 运算表达示
print(2.0+5)
# 将数据输出 到文件 中  注意点:1,所指定盘符存在2,使用file=
fp=open('E:/PyCharm2021.1.3Demo/demo01/text.txt','a+')
# a+如果文件不存在则创建,如存在则尾部水添加数据
print("hello world",file=fp)
fp.close()

# 不进行换行输出
print("hello",'world','python',"sc",'xiang')

运行结果

E:\PyCharm2021.1.3Demo\demo01\venv\Scripts\python.exe E:/PyCharm2021.1.3Demo/demo01/print函数.py
cctv
hello world
520
520.123212
7.0
hello world python sc xiang

Process finished with exit code 0

posted @ 2022-05-07 15:34  阿向向  阅读(141)  评论(0编辑  收藏  举报