Python中list字符串拼接

1、for循环拼接
word1 = ["abc", "d", "defg"]
word2 = ["abcddefg"]
str1, str2 = "", ""
for i in word1:
str1 += i
for j in word2:
str2 += j
print(str1 == str2)
2、使用join函数
str1 = "".join(word1)
str2 = "".join(word2)
print(str1 == str2)
3、生成器
word1 = ["abc", "d", "defg"]
word2 = ["abcddefg"]
str1, str2 = "", ""
str1 = "".join(i for i in word1)
str2 = "".join(j for j in word2)
print(str1 == str2)
不积硅步,无以至千里;不积小流,无以成江海