当前位置:首页 > Python教程 > python技巧

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
#worldprint(hello,end=)
print(world)
#hello world

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

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

flush=False

....

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


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!