Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
188 views
in Technique[技术] by (71.8m points)

使用中文后报错了一个gbk的错

在ubuntu-server上使用flask的flask-migrate脚本的输入中文后报了这个错

Traceback (most recent call last):
  File "manage.py", line 78, in <module>
    manager.run()
  File "/opt/py2-env/local/lib/python2.7/site-packages/flask_script/__init__.py", line 412, in run
    result = self.handle(sys.argv[0], sys.argv[1:])
  File "/opt/py2-env/local/lib/python2.7/site-packages/flask_script/__init__.py", line 383, in handle
    res = handle(*args, **config)
  File "/opt/py2-env/local/lib/python2.7/site-packages/flask_script/commands.py", line 216, in __call__
    return self.run(*args, **kwargs)
  File "manage.py", line 42, in create_role
    role = CMSRole(name=name.decode('gbk').encode('utf-8'),desc=desc.decode('gbk').encode('utf-8'),permissions=permissions)
UnicodeDecodeError: 'gbk' codec can't decode byte 0x98 in position 14: incomplete multibyte sequence

UnicodeDecodeError: 'gbk' codec can't decode byte 0x98 in position 14: incomplete multibyte sequence


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

是因为用的Python2开发,然后使用了解码和编码,但是项目迁移到Linux部署的时候,就可以不用这种解码和编码了


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...