码迷,mamicode.com
首页 > 编程语言 > 详细

python print及格式化

时间:2016-02-26 23:35:09      阅读:391      评论:0      收藏:0      [点我收藏+]

标签:

  • print(value,sep=‘ ‘,end=‘\n‘,file=sys.stdout, flush=False)

sep=‘ ‘默认空格


print(‘hello‘,‘world‘)
#hello world
print(‘hello‘,‘world‘,sep=‘|‘)
#hello|world

end=‘\n‘默认换行符

print(‘hello‘)
print(‘world‘)
#hello
#world

print(‘hello‘,end=‘ ‘)
print(‘world‘)
#hello world

file=sys.stdout默认输出到 系统的标准输出

with open(r‘d:\test.txt‘, ‘w‘) as txt:  
    print(‘abc‘,file=txt)
#输出字符串‘abc‘到D盘test.txt文件

flush=False

....

python print及格式化

标签:

原文地址:http://www.cnblogs.com/fj0716/p/5221961.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!