【发布时间】:2020-12-12 00:45:37
【问题描述】:
我想要完成的是读取 file A 然后通过过滤器进程运行它,然后用过滤后的单词写入 file B。我有其他系统可以在需要时调用它,但是,我需要根据我的猜测将其设为可执行文件。
我继续使用 pip 20.2.2 运行 Python 3.7.9
我安装了pyinstaller 来创建可执行文件。但在打包过程中,它达到了 1k 递归阈值。
根据我的观察知识,这意味着它正在循环调用自己,我不正确吗?我简单地重写了它,当我运行脚本时,它完全符合我的需要。但是,它仍然以循环的形式出现。我可能只是遗漏了一些简单的东西,所以感谢任何提供帮助的人。
另外,因为我对这些东西比较陌生,所以如果可以的话,请将术语保持在初学者的水平。但是,如果没有,我将使用我最好的朋友谷歌哈哈。
谢谢你们,这是我正在使用的代码:
from profanity_filter import ProfanityFilter
pf = ProfanityFilter()
contents = ''
checks = False
def filtering():
global contents
myfile = open("D:\\Pictures\\test_project\\Story_Time\\StoryTimeV1.txt")
contents = pf.censor(myfile.read())
myfile.close()
def filtering2():
global contents
global checks
myfile2 = open("D:\\Pictures\\test_project\\Story_Time\\StoryTimeV2.txt", "w")
myfile2.write(contents)
myfile2.close()
checks = True
while checks == False:
filtering()
filtering2()
给出的错误代码:
RecursionError: maximum recursion depth exceeded while calling a Python object
我也在正确的目录中等等。我相信你们中的一个人将能够了解我可能搞砸的事情哈哈。谢谢大家!
【问题讨论】: