我有以下代码
def printmylist( mylist ):
"""
print tree
"""
try:
for f in mylist:
printmylist( f )
except:
print( " " + mylist )
希望得到如下输出:
root
branch
leaf
leaf
但由于字符串是可枚举的,我得到
r
o
o
t
.
.
检查类型似乎是 unpythonic,那么 Pythonian 会怎么做呢?