# Demo: Now we have a big list with different base data bype(str,int,float) # we need to contact them into a fianl string src = ['abc', 123, 'defg', 49.8, '2021-01-21', '21:23:25'] # solution 1:[not recommended as it cost a lot of memory] dest = '' for x in src: dest += str(x) print(dest) #solution 2: [recommended] dest = ''.join((str(x) for x in src)) print(dest)
运行结果:
abc123defg49.82021-01-2121:23:25 abc123defg49.82021-01-2121:23:25 [Finished in 0.3s]



