【问题标题】:Python - Space between two characters [duplicate]Python - 两个字符之间的空格[重复]
【发布时间】:2013-09-14 19:25:35
【问题描述】:
def hashes(n):
    for x in range(0, n):
    print"#",

如果 n = 5,上面的代码会产生以下结果:

# # # # #

谁能提出一个解决方案,让字符之间没有空格?

#####

(Python 2.7)

【问题讨论】:

标签: python python-2.7


【解决方案1】:
def hashes(n):
    print "#" * n

【讨论】:

  • 不知道你能做到。谢谢!
【解决方案2】:

带有print功能

from __future__ import print_function
def hashes(n):
    for x in range(0, n):
        print("#", end='')

【讨论】:

    猜你喜欢
    • 2018-04-25
    • 1970-01-01
    • 2021-05-02
    • 2017-07-07
    • 2020-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    相关资源
    最近更新 更多