推荐学习书目
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
ivito
V2EX  ›  Python

使用 xlrd 模块读取 excel 中汉字 l 时编码问题

  •  
  •   ivito ·
    fireboyvt · Dec 22, 2014 · 6395 views
    This topic created in 4189 days ago, the information mentioned may be changed or developed.
    文件开始设置编码格式
    # -*- coding: utf-8 -*-
    读取excel中的某一列元素print时,会直接显示汉字的unicode编码
    wb = open_workbook(docname);
    table = wb.sheet_by_index(0);
    col = self.table.col_values(0);
    print col;
    而如果只读取某个单元格后print则能显示汉字
    col = self.table.col_values(1)[8];
    print col;
    为什么读取整列就不能显示汉字呢
    2 replies    2014-12-23 12:22:12 +08:00
    likaci
        1
    likaci  
       Dec 22, 2014
    太巧了,前天刚遇到这个问题
    ---
    这个和xlrd无关,读取的数据是存储在list中的。
    python2 list中的汉字没法直接打印

    http://blog.longwin.com.tw/2014/09/python-list-print-chinese-2014/
    ivito
        2
    ivito  
    OP
       Dec 23, 2014
    @likaci 靠谱,list中的中文直接打印会打印出unicode编码,如果单独打印list中的某一个元素可以打印出中文
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1132 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:13 · PVG 02:13 · LAX 11:13 · JFK 14:13
    ♥ Do have faith in what you're doing.