[英]How to print out the list items horizontally?
我有一個這樣的列表:
['0', '1', '1', '1', '2', '3', '4', '5', '7', '9']
我想打印以下項目:
0111234579
有人可以幫助我如何打印出我展示的物品嗎?
謝謝
list1 = ['0', '1', '1', '1', '2', '3', '4', '5', '7', '9']
print("".join(list1))
print(" ".join(arr))
arr
是你的清單
這很簡單
a=['0', '1', '1', '1', '2', '3', '4', '5', '7', '9']
for i in a:
print(i,end="")
寫print(i,end=" ")
如果你想要元素之間的空間。
或嘗試print(*a,sep="")
使用加入列表
list=[s ,o ,m ,e ,i ,t ,e, m ,s]
joinedlist="".join(list)
print(x) # prints with no spaces
# # # # with spaces # # # #
spacelist=" ".join(list)
print(spacelist)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.