# 错误: line 1: ascii
# Traceback (most recent call last):
# File "<maya console>", line 12, in <module>
# File "C:\Program Files\Autodesk\Maya2016\Python\lib\site-packages\oss2\resumable.py", line 73, in resumable_upload
# progress_callback=progress_callback)
# File "C:\Program Files\Autodesk\Maya2016\Python\lib\site-packages\oss2\api.py", line 347, in put_object
# headers = utils.set_content_type(http.CaseInsensitiveDict(headers), key)
# File "C:\Program Files\Autodesk\Maya2016\Python\lib\site-packages\oss2\utils.py", line 79, in set_content_type
# content_type = content_type_by_name(name)
# File "C:\Program Files\Autodesk\Maya2016\Python\lib\site-packages\oss2\utils.py", line 69, in content_type_by_name
# return mimetypes.guess_type(name)[0]
# File "C:\Program Files\Autodesk\Maya2016\bin\python27.zip\mimetypes.py", line 297, in guess_type
# init()
# File "C:\Program Files\Autodesk\Maya2016\bin\python27.zip\mimetypes.py", line 358, in init
# db.read_windows_registry()
# File "C:\Program Files\Autodesk\Maya2016\bin\python27.zip\mimetypes.py", line 258, in read_windows_registry
# for subkeyname in enum_types(hkcr):
# File "C:\Program Files\Autodesk\Maya2016\bin\python27.zip\mimetypes.py", line 249, in enum_types
# ctype = ctype.encode(default_encoding) # omit in 3.x!
# UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal not in range(128) #
网上找了一大堆,但只有这个方法能解决以上问题,解决方法添加以下:
# 设置编码
if sys.getdefaultencoding() != 'gbk':
reload(sys)
sys.setdefaultencoding('gbk')
default_encoding = sys.getdefaultencoding()
原因是windows编码用gbk,mac和linux默认用utf-8