python中split方法用法分析
本文實(shí)例講述了python中split方法用法。分享給大家供大家參考。具體分析如下:
split 是非常重要的字符串方法,它是join的逆方法,用來(lái)將字符串分割成序列
>>> '1+2+3+4+5'.split('+') ['1', '2', '3', '4', '5'] >>> 'usr/bin/env'.split('/') ['usr', 'bin', 'env'] >>> 'usr/bin/env'.split('/') ['usr', 'bin', 'env'] >>> '/usr/bin/env'.split('/') ['', 'usr', 'bin', 'env'] >>> 'using the default'.split() ['using', 'the', 'default']
如果不提供任何分隔符,程序會(huì)把所有空格作為分隔符
希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。
相關(guān)文章

Python基于遞歸算法求最小公倍數(shù)和最大公約數(shù)示例

django數(shù)據(jù)庫(kù)自動(dòng)重連的方法實(shí)例

python3模塊smtplib實(shí)現(xiàn)發(fā)送郵件功能

Python使用Bokeh實(shí)現(xiàn)交互式圖表的創(chuàng)建