如何在Python中指定多个分隔符进行split()操作?
input = "print{hello world};x = 2 + 3;"
x = input.split('{') #this works but not the desired OP
x = input.split('{','}') #error
x = input.split('{}') #this works but not the desired OP
期望的结果:
['print', 'hello world', ';x = 2 + 3;']
input.replace('}', '{').split('{')
- Kelly Bundy