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.
bd=raw_input('Enter your birthday(Use "." to seperate between day,month and year): ') for match in re.finditer('/.',bd): print "found"
次のコードは、「12.3.1990」と書いたときに 2 回検出されたと出力されるはずですが、何も出力されません。ありがとう!
バックスラッシュを使用して演算子をエスケープし.、リテラルに一致させる必要があります.。
.
for match in re.finditer('\.', bd):
コードは、リテラルのスラッシュと、改行以外のその他の文字を探しました。
デモ:
>>> import re >>> list(re.finditer('\.', '2013.10.29')) [<_sre.SRE_Match object at 0x100e8ad98>, <_sre.SRE_Match object at 0x100eaf308>]