我刚开始学习Python的2天前,对不起,如果我取得了明显的错误分割字符串用星号蟒蛇
strings: "brake break at * time" --> ["at","time"]
"strang strange I felt very *" --> ["very",""]
我想之前得到的字和后*
我尝试:
re.match(r"(?P(first_word)\w+) ('_*_') (?P(first_word)\w+)",strings).group('first_word')
为获得第一个字
re.match(r"(?P(first_word)\w+) ('_*_') (?P(first_word)\w+)",strings).group('last_word')
为获得最后的话
错误:没有重复
你试过'。 split('*')',因为它是一个你不想要的'*' – avasal