Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使字符串重复,例如:
而不是写print ('---------------------------')我该怎么做print ('-') * 60?
print ('---------------------------')
print ('-') * 60
你是如此接近:
>>> print('-' * 60) ------------------------------------------------------------
您需要将str值相乘,而不是函数的返回值print()。
str
print()
你非常接近 - 这是
print "-" * 60
在 Python 2 中,在 Python 3 中,它是
print ("-" * 60)