Python xlrd读为字符串

前端之家收集整理的这篇文章主要介绍了Python xlrd读为字符串前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在xlrd中从Excel读取特定单元格值时遇到困难.正在读取的值(日期值)正在转换为一个数字.我知道有解决方案将其转换成 python日期格式,但是可以直接读取xlrd中的字符串值吗?

解决方法

xlrd不将日期转换为float. Excel将日期存储为浮点数.

报价从the xlrd documentation(向下滚动一页):

Dates in Excel spreadsheets

In reality,there are no such things.
What you have are floating point
numbers and pIoUs hope. There are
several problems with Excel dates:

(1) Dates are not stored as a separate
data type; they are stored as floating
point numbers and you have to rely on
(a) the “number format” applied to
them in Excel and/or (b) knowing which
cells are supposed to have dates in
them. This module helps with (a) by
inspecting the format that has been
applied to each number cell; if it
appears to be a date format,the cell
is classified as a date rather than a
number.

另请参阅Cell类的部分,以及提取单元格类型(文本,数字,日期,布尔等)的各种Sheet方法.

还可以阅读可从www.python-excel.org访问的教程

原文链接:https://www.f2er.com/python/186046.html

猜你在找的Python相关文章