Groups
Sign in
Groups
python.tw
Conversations
About
Send feedback
Help
re模組問題
80 views
Skip to first unread message
partyp...@gmail.com
unread,
Nov 27, 2017, 9:52:00 AM
11/27/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to python.tw
'大雄有3隻羊2條狗,小明有狗3隻雞2隻,小花有1頭牛3隻豬2隻雞狗5條。'
使用re處理 計算大雄、小明、小花共有幾隻羊、狗、雞、豬、牛
請問我該如何用defaultdict統計
目前我只能將各種動物取出但不知道該如何相加同種動物
s4 = '大雄有3隻羊2條狗,小明有狗3隻雞2隻,小花有1頭牛3隻豬2隻雞狗5條。'
s = re.compile(r'([豬狗雞牛羊]\d+[頭隻條])|(\d+[條隻頭][豬狗雞牛羊])')
for m in s.finditer(s4):
b = m.group()
print(b)
Reply all
Reply to author
Forward
0 new messages