Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符串,比方说"MDP-A-17_MDP-A-23.3"。我希望这个字符串基于"-","_"和".".
"MDP-A-17_MDP-A-23.3"
"-"
"_"
"."
输出将是一个列表:
["MDP", "A", "17", "MDP", "A", "23", "3"]
很确定你可以使用 re.split,正如你的问题所暗示的那样......
import re s = "MDP-A-17_MDP-A-23.3" l = re.split(r'[-_.]',s)
检查文档... http://docs.python.org/2/library/re.html