我试图解析一组引号之间的随机字符串。 数据的形式总是:在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