我是Python新手,今天我正在基于列表在Python3.3上编写一个简单的测试程序。所以,我注意到当我输入制表符空格字符\t
时,输出闪烁,以至于我输入了换行符!下面给出一个示例:
def printlist(list_name,tabs=0):
for items in list_name:
if isinstance(items,list):
printlist(items,tabs)
else:
print(items)
for num in range(tabs):
print('\t') #tab-stops provide
list3 = [
'list no. 3',
['tree','stems','root'],
['human','hand','leg'],
['robot','microprocessor','motor']
]
printlist(list3,1)
输出是:
>>> ================================ RESTART ================================
>>>
list no. 3
tree
stems
root
human
hand
leg
robot
microprocessor
motor
>>>
但我想要的输出格式是:
list no. 3
tree
stems
root
human
hand
leg
robot
microprocessor
motor
[我想要标签而不是新行]
那么怎么可能呢?