私は python を学んでおり、5 つまたは 6 つの python ファイルを含むチュートリアル フォルダーがあります。それらの 1 つには正規表現関数 say が含まれていましfile_regex.py
た。問題は、フォルダー内の他のファイルを実行すると、常にfile_regex.py
実行されるため、の出力が得られることfile_regex.py
です。他のファイルに file_regex.py をインポートしていません。
file_regex.py
import re
sentence = ''' Jessica_is_27 year7s old, whereas John is 12 but Stephanie is 12 and Marco is 50 years '''
ages = re.findall(r'\d{1,3}', sentence)
names = re.findall('[A-Z][a-z]+', sentence) test = re.findall('\W', sentence)
print(ages)
print(names)
print(test)
これは、ファイル用のファイル__pycache__
を含むフォルダーが作成されたためです。.pyc
file_regex.py
regex.cpython-23.pyc
� Vo�U�@sjddlZdZejde�Zejde�Zejde�Zee�ee�ee�dS)�NzX Jessica_is_27 year7s old, whereas John is 12 but Stephanie is 12 and Marco is 50 years z\d{1,3}z[A-Z][a-z]+z\W)�re�sentence�findallZages�names�test�print�rr�!/home/sivasurya/tutorial/regex.py�<module>s
2 つの質問があります。
- ファイル
__pycache__
専用に作成されたフォルダーはなぜfile_regex.py
__pycache__
この問題のフォルダーまたは解決策を削除するにはどうすればよいですか (python -B file1.py
コマンドを使用して python ファイルをコンパイルしようとしましたが、うまくいきませんでした)
PS: 私は miniconda 環境 (python 3.x) で作業しています。