我正在学习python,我有一个包含5到6个python文件的教程文件夹。其中一个包含regex函数,比如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�s
我有两个问题:
__pycache__
文件夹只为file_regex.py
文件创建__pycache__
文件夹或解决此问题的方法(我尝试使用python -B file1.py
命令编译python文件,但没有成功)注:我在miniconda环境(python3.x)中工作,如果有帮助的话
这是不正确的。
__pycache__
文件夹的存在与文件是否运行无关。它只保存编译后的文件,不包含其他内容。在如果您的
file_regex.py
继续执行,这是因为其他文件或者
^{pr2}$在他们身上。在
我实际上把这个文件命名为
regex.py
。当我删除__pycache__
文件夹并将文件名改为file_regex.py
时,__pycache__
文件夹没有再次出现,问题就解决了。在相关问题 更多 >
编程相关推荐