我試圖解析一組引號之間的隨機字符串。 數據的形式總是:在python中解析字符串而不知道字符串
klheafoiehaiofa 「randomtextnamehere.ext」 fiojeaiof; jidoa; jfioda
我知道.EXT是什麼,那就是我要的是randomtextnamehere.ext,和它總是用「」分開。
目前我只能處理某些情況,但我希望能夠處理任何情況,如果我可以在第一個時間開始抓住「,並停止在第二個」,那就太好了。 !因爲有
致謝存在多於一組「每行的可能性
我試圖解析一組引號之間的隨機字符串。 數據的形式總是:在python中解析字符串而不知道字符串
klheafoiehaiofa 「randomtextnamehere.ext」 fiojeaiof; jidoa; jfioda
我知道.EXT是什麼,那就是我要的是randomtextnamehere.ext,和它總是用「」分開。
目前我只能處理某些情況,但我希望能夠處理任何情況,如果我可以在第一個時間開始抓住「,並停止在第二個」,那就太好了。 !因爲有
致謝存在多於一組「每行的可能性
可以使用str.split
方法:
Docstring:
S.split([sep [,maxsplit]]) -> list of strings
Return a list of the words in the string S, using sep as the
delimiter string. If maxsplit is given, at most maxsplit
splits are done. If sep is not specified or is None, any
whitespace string is a separator and empty strings are removed
from the result.
In [1]: s = 'klheafoiehaiofa"randomtextnamehere.ext"fiojeaiof;jidoa;jfioda'
In [2]: s.split('"', 2)[1]
Out[2]: 'randomtextnamehere.ext'
而且...什麼你有沒有寫你的代碼來解決這個問題? – Dusk 2013-04-25 04:15:03