[テスト開発エンジニアPythonインタビュー]リストの要素を文字列に変換する方法は?

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'>

 

おすすめ

転載: blog.csdn.net/jinhoward/article/details/106168399