python3 join函数_Python3 join函数和os.path.join用法详解
#Python3#author:lim#date:2019-01-14
#1.對數組進行操作
seq1 = ['hello','good','boy','doiido']
msg1= ' '.join(seq1)print(msg1)#輸出結果:hello good boy doiido
msg2 = ','.join(seq1)print(msg2)#輸出結果:hello,good,boy,doiido
#2.對字符串操作
seq2 = 'hello good boy doiido'msg3= ':'.join(seq2)print(msg3)#輸出結果:h:e:l:l:o: :g:o:o:d: :b:o:y: :d:o:i:i:d:o
#3.對元組進行操作
seq3 = ('hello','good','boy','doiido')
msg4= ':'.join(seq3)print(msg4)#輸出結果:hello:good:boy:doiido
#4.對字典進行操作
seq4 = {'hello':1,'good':2,'boy':3,'doiido':4}
msg5= ':'.join(seq4)print(msg5)#輸出結果:hello:good:boy:doiido
#5.合并目錄
importos
msg6= os.path.join('E:/hello/','/good/boy/','doiido')print(msg6)#輸出結果:E:/good/boy/doiido
總結
以上是生活随笔為你收集整理的python3 join函数_Python3 join函数和os.path.join用法详解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 苹果8p原装配件有什么
- 下一篇: 部落联赛怎么玩