运行 ❯
获取您的
个人 Python
服务器
×
更改方向
更改浅/深色主题
前往 Spaces
txt = "apple, banana, cherry" # setting the maxsplit parameter to 1, will return a list with 2 elements! x = txt.rsplit(", ", 1) print(x) # note that the result has only 2 elements "apple, banana" is the first element, and "cherry" is the last.
['apple, banana', 'cherry']