#-*-Coding:utf-8-*-#! /usr/bin/env python# author:xiao~~import openpyxlimport sysreload (SYS) sys.setdefaultencoding (' Utf-8 ') wb2=openpyxl. Workbook () wb2.save (' test1.xlsx ') print (' New success ')
Attach the shortened code
Error message
Traceback (most recent):
File "F:\PyCharm 5.0.4\helpers\pydev\pydevd.py", line 2411, <module>
Globals = Debugger.run (setup[' file '], none, none, Is_module)
File "F:\PyCharm 5.0.4\helpers\pydev\pydevd.py", line 1802, in run
Launch (file, globals, locals) # Execute the Script
File "d:/test/yf_test/conf/test1.py", line 5, <module>
Import OPENPYXL
File "F:\Python27\lib\site-packages\openpyxl\__init__.py", line +, in <module>
From Openpyxl.workbook Import Workbook
File "F:\Python27\lib\site-packages\openpyxl\workbook\__init__.py", line 5, <module>
From. Workbook Import Workbook
File "F:\Python27\lib\site-packages\openpyxl\workbook\workbook.py", line +, in <module>
From Openpyxl.writer.excel import Save_workbook, Save_dump
File "F:\Python27\lib\site-packages\openpyxl\writer\excel.py", line up, in <module>
From openpyxl.packaging.manifest Import manifest
File "F:\Python27\lib\site-packages\openpyxl\packaging\manifest.py", line $, in <module>
Mimetypes.init ()
File "F:\Python27\lib\mimetypes.py", Line 358, in Init
Db.read_windows_registry ()
File "F:\Python27\lib\mimetypes.py", line 258, in Read_windows_registry
For SubkeyName in Enum_types (HKCR):
File "F:\Python27\lib\mimetypes.py", line 249, in Enum_types
CType = Ctype.encode (default_encoding) # Omit in 3.x!
Unicodedecodeerror: ' ASCII ' codec can ' t decode byte 0xd7 in position 20:ordinal not in range (128)
You can F:\Python27\Lib\mimetypes.py this document by masking it
I have verified that it can be successfully resolved
Python2 using OPENPYXL error unicodedecodeerror: ' ASCII ' codec can ' t decode byte 0xd7 in position 20:ordinal not in range (128) Workaround