0
点赞
收藏
分享

微信扫一扫

Python入门--输出函数print

静鸡鸡的JC 2022-02-04 阅读 122
#可以输出数字
print(5217)
print(13.14)

#可以输出字符串单引号双引号都可
print('hello world')
print("hello world")

#可以输出含有运算符的表达式,会计算表达式的结果
print(3+1)

#可以将数据输出到文件中,注意file=
fp=open('D:\zhouj\Documents\Pythontest/text.txt','a+')
#fp=open('D:/text.txt','a+')#'a+'如果文件不存在就创建,存在就在文件内容后面继续追加
print('hello world',file=fp)
fp.close()

#不进行换行输出(输出内容在一行当中)
print('hello','word','Python')
举报

相关推荐

0 条评论