【发布时间】:2015-09-29 20:16:28
【问题描述】:
我查看了以前的条目,由于人们使用的代码,它们相对难以理解。我已经使用了 join 功能,但它不起作用。我正在尝试将列表列表加入单个字符串,输出应该有每个加入的子列表用空格分隔:
Five = 5
Converted = [chr(i) for i in addof]
#converts the numbers into letters of a not mentioned here variable(addof)
grouped = [converted[i:i+five] for i in range(0, len(converted), five)]
#groups the letters into groups of five
print("".join(map(str, grouped)))
#trying to use the join function in order to remove brackets etc. but it doesnt work
####################### OUTPUT ######################
['V', 'r', 'p', 'h', 'z']['k', 'h', 'u', 'h', 'l']['q', 'o', 'd', 'P', 'd']['q', 'f', 'k', 'd', '/']['l', 'q', 'd', 's', 'o']['d', 'f', 'h', 'z', 'k']['r', 'v', 'h', 'q', 'd']['p', 'h', 'L', 'g', 'r']
有人可以帮忙吗? 谢谢
【问题讨论】:
-
括号是什么意思,它们是从哪里来的?
-
在输出中你有方括号,但我不想要那些。
-
你的意思是你有一个列表列表并且你想要一个列表或者究竟是什么?如果您添加原始结构,则更容易理解您想要的内容
-
您意识到在列表上调用
map(str会给您一个列表的字符串表示形式吗? -
那行得通,非常感谢:)
标签: python join dictionary