| 
 | 
 
 
发表于 2020-7-28 18:07:21
|
显示全部楼层
   本楼为最佳答案    
 
 
  IDLE输入一下指令: 
- Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
 
 - Type "help", "copyright", "credits" or "license()" for more information.
 
 - >>> help(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的帮助文档 
 
 
print(...) 
    print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) 
     
    Prints the values to a stream, or to sys.stdout by default. 
    这里是他的属性定义: 
    file:  表示在哪个文件写东西(默认值为None,就是不往文件里写东西). 
    sep:   表示每一个逗号分隔的字符串里的分隔字符串(默认值为空格). 
    end: 表示字符串末尾的字符串,默认一个换行符(所以每个print之间都会换一行。end=""的意思就是不换行). ## 重点!!!也是你问的问题 
    flush: 是否马上把数据写到文件里,默认值False,就是不马上把数据写到文件里(这个属性基本没用). 
 
 
再次强调重点: 
end: 表示字符串末尾的字符串,默认一个换行符(所以每个print之间都会换一行。end=""的意思就是不换行). ## 重点!!!也是你问的问题 
 
不懂再问,懂的话请设置最佳答案 
 |   
 
 
 
 |