![](/img/trans.png)
[英]How to print label multiple times for contour lines using clabels in matplotlib?
[英]python basic question how to print the name 10 times in multiple lines without using for loop and in a string
name = input("What's your name?? ")
print(10 * name )
連續打印名稱 10 次,但是如果我希望將名稱在列中打印 10 次,我該怎么做謝謝
您可以在名稱末尾簡單地 append 換行符:
name = input("What's your name??")
print(10 * (name + '\n'))
\n
是換行符 - 在它之后打印的任何內容都會 go 到下一行。
name = input("What's your name?? ")
print(10 * (name+"\n") )
您可以使用 '\n' (換行符)作為分隔符打印您的姓名的 10 倍:
name = input("What's your name??")
print(*(name for i in range(10)), sep='\n')
您也可以使用itertools.repeat
:
from itertools import repeat
name = input("What's your name??")
print(*repeat(name, 10), sep='\n')
for i in range(1,11,+1): #通過使用 for 循環 i=name
打印(一)
name = input("What's your name?? ")
print(10 * (name+'\n'))
您可以從上面的代碼中使用它是 python 的漂亮字符,但我建議您使用:
name = input("What's your name?? ")
for i in range(10):
print(name)
這將是真正的編碼員的工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.