+ 12

What is the best way to split a string in Python?

4th Feb 2020, 6:20 PM
SHADOW 🌀
SHADOW 🌀 - avatar
3 Respostas
+ 1
Alternatively, you can use the split method from the re module if you want to split by regular expressions: import re pattern = '\s?\+\s?' # a plus sign between 0, 1 spaces from left and right string = '1 +2 + 3+ 4+5' re.split(pattern, string) >>> ['1', '2', '3', '4', '5']
4th Feb 2020, 7:48 PM
Zuke
Zuke - avatar
0
print("python is the best of /n all result:python is the best of all
15th Feb 2020, 9:48 AM
Coder
Coder - avatar