Life is short, you need Python

Python - split and join

>>> s="I am fine"
>>> s
'I am fine'
>>> s.split(" ")
[
'I', 'am', 'fine']
>>> sList=s.split(" ")
>>> sList
[
'I', 'am', 'fine']
>>> "%".join(sList)
'I%am%fine'

Notes:

1)String is transfered to a List by split method

2)List can be joined a string by join method

posted @ 2010-08-20 10:33  runfox545  阅读(632)  评论(0编辑  收藏  举报
白月黑羽 Python教程 白月黑羽Python