python print及格式化

  • 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

....

posted @ 2016-02-26 22:18  fj0716  阅读(279)  评论(0编辑  收藏  举报