推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
littlepython
V2EX  ›  Python

centos6.8 系统编码和 Python 文件的编码问题

  •  
  •   littlepython · Aug 24, 2019 · 2772 views
    This topic created in 2596 days ago, the information mentioned may be changed or developed.
    每次登录显示这种问题
    -bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
    -bash: ulimit: open files: cannot modify limit: Operation not permitted

    然后运行 python 文件 打印中文日志就会出现
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)

    这种该怎么设置正常呀 用 python 打印出来的系统编码是 ANSI 这种
    3 replies  •  2019-08-25 13:46:38 +08:00
    hangvane
        1
    hangvane  
       Aug 24, 2019   ❤️ 1
    试试这条?我用来解决 docker 容器中无法正常显示中文的问题
    echo "export LANG=C.UTF-8" >>/etc/profile
    littlepython
        2
    littlepython  
    OP
       Aug 24, 2019
    @hangvane 好像不行
    tempdban
        3
    tempdban  
       Aug 25, 2019 via Android
    你是不是自己换过 libc
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2278 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 07:49 · PVG 15:49 · LAX 00:49 · JFK 03:49
    ♥ Do have faith in what you're doing.