我在包含hangman游戏单词库的目录中使用其他.txt文件构建了一个hangman游戏,这些文件是在我使用pyinstaller打包时从hangman.py文件中打开的path\to\pyinstaller.exe hangman.py --onefile
,但这不允许在可执行文件中使用.txt文件。我如何打包.txt文件,以便可执行文件可以正常运行?
答案 0 :(得分:0)
您可以使用
from openpyxl import load_workbook
wb = load_workbook('./logo.xlsx')
wb.save('logo_new.xlsx')
或使用文件列表编辑规范文件,即
Traceback (most recent call last):
File "c:\Users\Sarmad Gulzar\Documents\Visual Studio Code\Python\Excel\test.py", line 3, in <module>
wb.save("new3.xlsx")
File "C:\Python37\lib\site-packages\openpyxl\workbook\workbook.py", line 391, in save
save_workbook(self, filename)
File "C:\Python37\lib\site-packages\openpyxl\writer\excel.py", line 284, in save_workbook
writer.save(filename)
File "C:\Python37\lib\site-packages\openpyxl\writer\excel.py", line 266, in save
self.write_data()
File "C:\Python37\lib\site-packages\openpyxl\writer\excel.py", line 85, in write_data
self._write_images()
File "C:\Python37\lib\site-packages\openpyxl\writer\excel.py", line 122, in _write_images
self._archive.writestr(img.path[1:], img._data())
File "C:\Python37\lib\site-packages\openpyxl\drawing\image.py", line 64, in _data
img = _import_image(self.ref)
File "C:\Python37\lib\site-packages\openpyxl\drawing\image.py", line 33, in _import_image
img = PILImage.open(img)
File "C:\Python37\lib\site-packages\PIL\Image.py", line 2638, in open
fp.seek(0)
ValueError: I/O operation on closed file.