學習內容:
1.字符串轉列表
2.列表轉字符串
1. 字符串轉列表
s ='hello python !'
li = s.split(' ') #注意:引號內有空格
print (li)
輸出:
['hello', 'python', '!']
2. 列表轉字符串
li = ['hello', 'python', '!'] s = ' '.join(li) #注意:引號內有空格 print(s) 輸出: hello python !
1.字符串轉列表
2.列表轉字符串
s ='hello python !'
li = s.split(' ') #注意:引號內有空格
print (li)
輸出:
['hello', 'python', '!']
li = ['hello', 'python', '!'] s = ' '.join(li) #注意:引號內有空格 print(s) 輸出: hello python !
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。