Python 3:给定一个字符串(一个等式),返回一个正整数和负整数的列表.我尝试了各种正则表达式和列表理解解决方案无济于事.
给定等式4 + 3x或-5 + 2y或-7y-2x返回:[4,3],[ - 5,2],[ - 7,-2]
输入
str = '-7y-2x'
产量
my_list = [-7, -2]
python regex math list-comprehension python-3.x
list-comprehension ×1
math ×1
python ×1
python-3.x ×1
regex ×1