当从许多子串创建一个字符串时,更多的是pythonic - +或%?
big_string = string1 + string2 + ... + stringN
big_string = ''
for i in range(n):
big_string+=str(i)
或
big_string = "%s%s...%s" % (string1, string2, ... , stringN)
big_string = ''
for i in range(n):
big_string = "%s%s" % (big_string, str(i))
答案 0 :(得分:11)
big_string = ''.join([string1, string2, ..., stringN])
答案 1 :(得分:-2)
big_string = reduce(lambda x, y: x + y, [string1, string2, ..., stringN], "")