python面試題目解析:
題目:如何將一個列表中的元素轉化爲字符串?,比如L = [1, 2, 3, 5, 6],如何得出 '12356'?
#coding=utf-8
#Date:2020-05-17 1:24
#Version:V1.0.0
#Author:honghao.jhh
'''
面試題目:L = [1, 2, 3, 5, 6,7,8],如何得出 '1235678'?
'''
stringA=''
L = [1,2,3,5,6,7,8]
for i in L:
stringA= stringA+str(i)
print 'Result is:' + stringA
print 'Result type is:' + str(type(stringA))
代碼運行結果如下:
Result is:1235678
Result type is:<type 'str'>