python的字符串与列表拼接要怎么弄
a = ("python")b = ["good","nice","great"]
如何让结果变成:
["pythongood",["pythonnice"],"pythongreat"] ["pythongood","pythonnice","pythongreat"]
这样的,中间的那个 []多打了
本帖最后由 Twilight6 于 2020-7-28 15:42 编辑
for 循环和 a 字符串拼接就好,如果想在原列表上进行改变就这样:
a = ("python") # 实际上这里 相当于a = "python"
b = ["good","nice","great"]
for i in range(len(b)):
b = a+b
print(b)
重新创建个列表就这样,用列表推导式了:
a = ("python")
b = ["good","nice","great"]
new =
print(new)
a = ("python")
b = ["good","nice","great"]
s = for j in range(len(b))]
print(s)
页:
[1]