【发布时间】:2021-03-26 11:15:06
【问题描述】:
我正在尝试将文本拆分为 Python 中的列表,但我想排除双引号之间的文本和空格。 简而言之,是这样的:
def splitdq(text):
# do spliting stuff here...
test = 'The "quick brown fox" jumps over the "lazy dog."'
print(splitdq(test))
>>> ["The", "quick brown fox", "jumps", "over", "the", "lazy dog."]
我找到了一些解决方案,但他们要么保留引号,要么就是不起作用。 那么,有没有办法在 Python 中做到这一点?
【问题讨论】:
-
是的,这正是我想要的,谢谢 :)
标签: python arrays python-3.x string list