Python
1words = ["orange", "october", "octpus", "order", "banana", "baby","busy","beautiful","wonderful"] 2pattern = r"oc.*" 3print("ocで始まるパターン=", pattern) 4for word in words: 5 if re.match(pattern,word): 6 print("-",word)
というコードを打ちました。
そのエラーが
Traceback (most recent call last):
File "C:\Users\detec\Desktop\re.py", line 1, in <module>
import re
File "C:\Users\detec\Desktop\re.py", line 7, in <module>
if re.match(pattern,word):
AttributeError: module 're' has no attribute 'match'
でした。
書籍の通りに打っているはずなのですが、エラーになります。
どうしたら様でしょうか?
回答2件
あなたの回答
tips
プレビュー