Python 將列表中的元素轉化爲字符串

colors = ['red', 'blue', 'yellow', 12, 3.14] str1 = str(colors)[1:-1] str1 >> "'red', 'blue', 'yellow', 12, 3.14" 這種方式,會將每個元素拼到字符串中,從另外一個角度看,他只是把中括號替換成了引號。python colors = ['red', 'blue', 'yellow'] s
相關文章
相關標籤/搜索