def printable(l):
for i in range(len(l)):
for j in range(len(l[i])):
print(l[i][j])
print()
tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
printable(tableData)
例如,如果我有一个数据
bob,sob,cob,dab
如果我打印它使用循环,然后它将被打印一个接一个我想要的是 打印完bob和sob后,我希望光标回到上方,然后打印cob-dab
first:print
bob
sob
second:then cursor comes back up and print
cob
dab
the output i wanted is
bob cob
sob dab
如果删除上述数据中的dab,则输出应为
鲍勃·科布
呜咽
这在Python中是可能的吗?
有人能举个例子吗
你能做到的
输出
编辑-长度不等时展开答案: 使用^{}
输出
默认的fillvalue是
None
——如果您愿意,可以保留它展开其中一个答案并使用简单列表(bob、sob、cob、dab),可以使用基于一维列表中索引位置的模,然后附加“\n”以创建具有适当间距的新行:
输出:
相关问题 更多 >
编程相关推荐