Python中l(wèi)ist字符串拼接

1、for循環(huán)拼接
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函數(shù)
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)
不積硅步,無以至千里;不積小流,無以成江海