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.
申し訳ありませんが、私はpythonが初めてです。次のような式から変数を抽出しようとしています:
ABC=DEF=5 C=DF/10
ABC、DEF、C、DFなどを抽出したい
これは、あなたが与えた例では機能しますが、もちろん、より複雑なコードでは失敗します。
>>> import re >>> text = '''ABC=DEF=5 C=DF/10''' >>> re.findall(r'[a-zA-Z_]\w*', text) ['ABC', 'DEF', 'C', 'DF']