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.
文字列から何かを照合しようとしており、一致したすべての文字列をリストに入れたいと考えています。どうすればいいですか?
現在、私はこれを使用しています
myStr = 'one two one three' match = re.match(r'one', myStr)
しかし、をmatch使用して変数の内容を印刷するprint m.group()と、最初に出現したものだけが表示されます。すべてのオカレンスを取得してから、それらの値をすべてリストに入れたいと思います。
match
print m.group()
>>> import re >>> re.findall(r'one', 'one two one three') ['one', 'one']