pythonresplit
發布時間: 2025-06-29 09:31:41
❶ 請問python3中的re.split與re.findall的區別
你的Python程序輸出結果是對的.
re.split是以re.compile中的正則表達式對字元串進行切分.
re.findall是以re.compile中的正則表達式對字元串進行匹配.
就拿你的例子來說吧,
re.split是以數字為邊界對字元串'one1two2three3four4'進行切分,得到['one','two','three','four','']五個字元串
re.findall是匹配字元串'one1two2three3four4'中的所有數字,得到['1','2','3','4']四個數字
熱點內容