鱼C论坛

 找回密码
 立即注册
查看: 1021|回复: 1

[已解决]问一下 end= 的具体作用和描述

[复制链接]
发表于 2018-6-15 16:43:05 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. >>> shu = "asdfghjk"
  2. >>> for i in shu:
  3.         print(i)

  4.        
  5. a
  6. s
  7. d
  8. f
  9. g
  10. h
  11. j
  12. k
复制代码

  1. >>> shu = "asdfgg"
  2. >>> for i in shu:
  3.         print(i,end=" ")

  4.        
  5. a s d f g g
复制代码


  1. >>> shu = "adsdsdffa"
  2. >>> for i in shu:
  3.         print(i,end="1")

  4.        
  5. a1d1s1d1s1d1f1f1a1
  6. >>>
复制代码



end=是换行吗 ?还是什么?不太理解啊
最佳答案
2018-6-15 17:20:49
end是print()函数的结束符,默认是 回车,比如你的第一个代码,原则上可以是任意字符,比如第二个代码(空格)、第三个代码(1)

>>> 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.
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-6-15 17:20:49 | 显示全部楼层    本楼为最佳答案   
end是print()函数的结束符,默认是 回车,比如你的第一个代码,原则上可以是任意字符,比如第二个代码(空格)、第三个代码(1)

>>> 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.
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-3-29 20:55

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表