print()

通过输入 help(print) 得到 print 内建函数的参数

Help on built-in function print in module builtins:

print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.

print() 函数的几个参数:

  • value 是值的意思,可以传出字符串、数字、列表等
  • sep 默认为空格,在打印的时候两个值之间填充空格
  • end 默认是换行,当不想要换行显示的时候可以修改默认值
  • file 表示了 print 和 sys.stdout 的关系,print 函数默认已经是标准化输出
  • flush 是刷新的意思
'''
使用一个循环容易看出效果,分隔符用 123 代替,默认的换行改成了制表符,可以看到打印之后光标没有到下一行
'''
>>> for i in range(2):
print("hello", "world", sep='123', end='\t') hello123world hello123world >>>

这里有一篇有趣的文章,通过调整 flush 参数实现动态图的效果python的print(flush=True)实现动态loading......效果

【Python】【Head First Python】【chapter1】2 - sys.stdout 和 print 的区别的更多相关文章

  1. python 以标准输出(sys.stdout)为例,看python的标准输入、标准错误输出

    看了一个博客,挺不错的.http://www.cnblogs.com/turtle-fly/p/3280519.html 标准输出(sys.stdout)对应的操作就是print(打印)了,标准输入( ...

  2. Python 标准输出 sys.stdout 重定向(转)

    add by zhj: 其实很少使用sys.stdout,之前django的manage.py命令的源码中使用了sys.stdout和sys.stderr,所以专门查了一下 这两个命令与print的区 ...

  3. python之sys.stdout、sys.stdin

    转自:http://www.cnblogs.com/turtle-fly/p/3280519.html 本文环境:Python 2.7  使用 print obj 而非 print(obj) sys. ...

  4. Python 标准输出 sys.stdout 重定向

    本文环境:Python 2.7 使用 print obj 而非 print(obj) 一些背景 sys.stdout 与 print 当我们在 Python 中打印对象调用 print obj 时候, ...

  5. python中sys.stdout、sys.stdin

    如果需要更好的控制输出,而print不能满足需求,sys.stdout,sys.stdin,sys.stderr就是你需要的. 1. sys.stdout与print: 在python中调用print ...

  6. 【python】print · sys.stdout · sys.stderr

    参考文档 Python重定向标准输入.标准输出和标准错误 http://blog.csdn.net/lanbing510/article/details/8487997 python重定向sys.st ...

  7. python重定向sys.stdin、sys.stdout和sys.stderr

    转自:https://www.cnblogs.com/guyuyuan/p/6885448.html 标准输入.标准输出和错误输出. 标准输入:一般是键盘.stdin对象为解释器提供输入字符流,一般使 ...

  8. python之sys.stdout、sys.stdin以及设置打印到日志文件等

    转自:https://www.cnblogs.com/BigFishFly/p/6622784.html python之sys.stdout.sys.stdin 转自:http://www.cnblo ...

  9. python sys.stdin、sys.stdout和sys.stderr

    学习并转载自  https://www.cnblogs.com/guyuyuan/p/6885448.html 标准输入:一般是键盘.stdin对象为解释器提供输入字符流,一般使用raw_input( ...

随机推荐

  1. windos下安装多个mysql服务

    最近需要使用Mysql制造大量数据,需要多个Mysql服务器.一开始的解决方案是使用多个windows机器.实体机不够,则用虚拟机来搞.但,,,,安装多个虚拟机…….好吧, 在网上查了下,有使用单个机 ...

  2. [NOIP2015提高组]子串

    题目:洛谷P2679.Vijos P1982.codevs4560.UOJ#149. 题目大意:有长度为n的A串和长度为m的B串.现在要从A串中取出k个互不重叠的子串,使它们按顺序相连后得到B串.问有 ...

  3. python main函数

    关于Python的主(main)函数问题 2007-07-23 19:14 初次接触Python的人会很不习惯Python没有main主函数.这里简单的介绍一下,在Python中使用main函数的方法 ...

  4. Android——4.2.2 文件系统文件夹分析

    近期公司要整android内部培训,分配给我写个培训文档.这里记录例如以下: 撰写不易,转载请注明出处:http://blog.csdn.net/jscese/article/details/4089 ...

  5. 理解Linq查询

    using System; using System.Linq; static class Program { static double Square(double n) { Console.Wri ...

  6. Redis封装之List

    /// <summary> /// Redis list的实现为一个双向链表,即可以支持反向查找和遍历,更方便操作,不过带来了部分额外的内存开销, /// Redis内部的很多实现,包括发 ...

  7. 暑假集训-WHUST 2015 Summer Contest #0.2

    ID Origin Title 10 / 55 Problem A Gym 100625A Administrative Difficulties   4 / 6 Problem B Gym 1006 ...

  8. P1824 进击的奶牛

    题目描述 Farmer John建造了一个有N(2<=N<=100,000)个隔间的牛棚,这些隔间分布在一条直线上,坐标是x1,...,xN (0<=xi<=1,000,000 ...

  9. Linux软件万花筒

    650) this.width=650;" border="0" alt="" src="http://img1.51cto.com/att ...

  10. tomcat-servlet-client

    headfirst的一个图,但解决了我的一个疑问