Python中的print,是我们学习Python的第一个命令,它可以输出数字,字符串,运算符表达式,以及输出到文件。
以下是我们的测试,大家可以照着敲一下,知道输出数字或者字符串的格式就可以了:
#可以输出数字 print(401) print(98.5) #可以输出含有运算符的表达式 print(3+4)
#可以输出字符串 print(‘hello world’) print(“hello world”) #print(hello world) 这种形式是错误的
#将数据输出到文件中
fp=open(‘E:/muchen.txt’,‘a+’) #a+表示有文件就追加,没文件就新建 print(‘hell world’,file=fp) fp.close()
#不进行换行输出 print(“hello”,“world”,“python”)
查看更多关于【Python从零到壹】print的使用方法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did127999