zoukankan      html  css  js  c++  java
  • linux终端出现UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-2: ordinal not in range(128) 中文乱码报错的解决方案

    linux服务器上执行python打印脚本 ,汉字乱码 。。。。我觉得挺常见挺简单的一个问题 ,百度半天,尝试半天楞是没解决,。。。好气

    尝试过的:

    下载语言包软件

    配置语言文件

    忘记哪个文件了 

    或者在代码里加sys如果

    如果你也是尝试之后没解决的,可以试试我下面的方法。我是解决了,。,,。真香

    解决:
    (1)设置环境变量LANG
    修改~/.bash_profile文件,执行:

    export LANG=“en_US.UTF-8” >> ~/.bash_profile
    source ~/.bash_profile

    (2)给python执行命令添加utf-8 ,执行:

    export PYTHONIOENCODING=utf-8 >> ~/.bashrc
    source ~/.bashrc
    

  • 相关阅读:
    realsense d435i qt 测试
    realsense d435i 数据 测试
    realsense d435i测试
    ubuntu torch GPU yolov5
    IfcLayeredItem
    ubuntu大服务器 pytorch环境配置
    condarc内容
    realsense point cloud
    yolov5 环境配置
    pip error
  • 原文地址:https://www.cnblogs.com/beile/p/12980149.html
Copyright © 2011-2022 走看看