我剛開始學習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