Python2 using OPENPYXL error unicodedecodeerror: ' ASCII ' codec can ' t decode byte 0xd7 in position 20:ordinal not in range (128) Resolve Method

Source: Internet
Author: User

#-*-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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.