【发布时间】:2015-08-21 17:04:15
【问题描述】:
我有一个清单
string = ['a', 'b', 'c', 'd', 'e', 'f']
我试图在列表的每 2 个字符之间留一个空格,这样它就会变成这样:
['a', 'b', ' ', 'c', 'd', ' ', 'e', 'f']
我试过这个:
test = 0
while test != len(string):
for i in range(2):
string.append(' ')
test = test + 1
print (string)
但它给出了这个错误:
Traceback (most recent call last):
File "D:/Python/New folder (3)/test.py", line 8, in <module>
string.append(' ')
MemoryError
【问题讨论】:
-
为什么有这么多反对票?这是一个合理的问题。
-
它没有显示出研究成果,对任何做过研究的人都不太可能有用。