在不知道字符串中的内容的情况下用python解析字符串

在不知道字符串中的内容的情况下用python解析字符串,python,string,parsing,quotes,Python,String,Parsing,Quotes,我试图解析一组引号之间的随机字符串。 数据的格式始终为: klheafoiehaiofa“randomtextnamehere.ext”fiojaiof;吉多阿;jfioda 我知道.ext是什么,我想要的是randomtextnamehere.ext,它总是用“”分隔 目前我只能处理某些案件,但我希望能够处理任何案件,如果我能从第一个“抓起”到第二个“停下来”,那就太好了。因为每一行可能有不止一组“数据” 谢谢!您可以使用以下方法: 您可以使用以下方法: 还有…到目前为止,您在代码中编写了

我试图解析一组引号之间的随机字符串。 数据的格式始终为:

klheafoiehaiofa“randomtextnamehere.ext”fiojaiof;吉多阿;jfioda

我知道.ext是什么,我想要的是randomtextnamehere.ext,它总是用“”分隔

目前我只能处理某些案件,但我希望能够处理任何案件,如果我能从第一个“抓起”到第二个“停下来”,那就太好了。因为每一行可能有不止一组“数据”

谢谢!

您可以使用以下方法:


您可以使用以下方法:



还有…到目前为止,您在代码中编写了什么来解决这个问题?还有…到目前为止,您在代码中编写了什么来解决这个问题?很好。从功能上讲,第二个split参数是不必要的。@wim--您当然是对的,我试图证明您只能在separat的前两次出现时显式拆分字符串or.Good。从功能上讲,第二个参数split是不必要的。@wim--您当然是对的,我试图证明您只能在分隔符的前两次出现时显式拆分字符串。
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 maxsplitsplits 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'