>>> s = '|Action and Adventure|Drama|Science-Fiction|Fantasy|'
>>>
>>> [item for item in s.split('|') if item.strip()]
['Action and Adventure', 'Drama', 'Science-Fiction', 'Fantasy']
>>>
Run Code Online (Sandbox Code Playgroud)
如果你想要一个元组,那么:
>>> tuple(item for item in s.split('|') if item.strip())
('Action and Adventure', 'Drama', 'Science-Fiction', 'Fantasy')
>>>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10638 次 |
| 最近记录: |