我已经编写了一个python脚本来解析文本文件。 .py工作正常,但是当我尝试使用pyinstaller生成exe文件时,程序无法正常工作。经过一些调试(将执行过程中的一些信息从不同位置打印到ouput.text中),我发现程序停止在str.replace函数上。
因为这是内置方法。我是否应该将某些东西(模块,标志,..等)传递给pyinstaller以便生成可运行的exe文件?
Pyinstaller命令:
pyinstaller -F parse.py
parse.py:
InputFile = open('./input.txt', 'r')
InputLines = InputFile.readlines()
if len(InputLines ) != 0:
for line in InputLines:
words = line.split()
if len(words) != 0 :
if words[0] == 'ticket':
outputText.write('ticket'+words[1]) # to trace the execution
ticketObj= ticket(words[1].replace('{', '')) #create new obj
outputText.write('replacement done ') # to trace the execution
input.text:
ticket ticket_1{
ticket details..
}
ouput.text,如果生成的.exe文件运行:
ticket ticket_1{
ouput.text parse.py文件运行:
ticket ticket_1{
replacement done