【发布时间】:2022-09-29 22:05:05
【问题描述】:
我想根据逗号进行拆分,但想保留其中包含相关逗号的句子。该字符串在字符串之间没有任何类型的双引号。 例如:
string = \'The Three Musketeers, are, Athos, Porthos and Aramis\'
输出:
str_to_list = [\'The Three Musketeers\', \'are\', \'Athos, Porthos and Aramis\']
我想根据逗号进行拆分,但想保留其中包含相关逗号的句子。该字符串在字符串之间没有任何类型的双引号。 例如:
string = \'The Three Musketeers, are, Athos, Porthos and Aramis\'
输出:
str_to_list = [\'The Three Musketeers\', \'are\', \'Athos, Porthos and Aramis\']
尝试这个
string = 'The Three Musketeers, are, Athos, Porthos and Aramis'
string.split(',')
【讨论】: