首页 > 解决方案 > 如何在python中拆分字符串但将分组符号中的任何内容保留为一个

问题描述

我想取一个字符串:

x = 'The following is a string: \'Here is a nice python string\'

并拆分它,但保持内部字符串完整,以便返回:

['The', 'following', 'is', 'a', 'string:', '\'Here is a nice python string \'']

{}对于or[]或,这应该是相同的(),但是, not <>

标签: pythonstring

解决方案


推荐阅读