【发布时间】:2020-06-20 05:42:16
【问题描述】:
我有一个字符串'Predicate(big,small)'
如何从中派生以下字符串列表,['Predicate','(','big',',','small',')']
名称可以是任何东西,元素之间也可以有空格(我需要从列表中取出空格),Predicate (big, small)
到目前为止我已经尝试过这个,但这显然不是我想要的结果
>>> str1 = 'Predicate(big,small)'
>>> list(map(str,str1))
输出:
['P', 'r', 'e', 'd', 'i', 'c', 'a', 't', 'e', '(', 'b', 'i', 'g', ',', 's', 'm', 'a', 'l', 'l', ')']
【问题讨论】:
标签: python arrays python-3.x string list