I'm trying to use pyexcel
but am having an issue following the instructions. On the documentation, it says to run this code:
我正在尝试使用pyexcel,但是按照说明有问题。在文档上,它说运行这段代码:
>>> import pyexcel
>>> import json
>>> book_dict = pyexcel.get_book_dict(file_name="book.xls")
>>> isinstance(book_dict, OrderedDict)
True
>>> for key, item in book_dict.items():
... print(json.dumps({key: item}))
{"Sheet 1": [[1, 2, 3], [4, 5, 6], [7, 8, 9]]}
{"Sheet 2": [["X", "Y", "Z"], [1, 2, 3], [4, 5, 6]]}
{"Sheet 3": [["O", "P", "Q"], [3, 2, 1], [4, 3, 2]]}
However, my interpreter in Python 2.7 says that get_book_dict
is not a valid attribute. Any ideas how I should proceed?
但是,我在Python 2.7中的解释器说get_book_dict不是一个有效的属性。我该怎么做呢?
2 个解决方案
#1
1
I exactly don't know the reason of the error but I got a workaround for you. Try:
我完全不知道这个错误的原因,但我有一个解决办法。试一试:
>>> from pyexcel.core import *
>>> get_book_dict
>>> <function get_book_dict at 0x7fb8cc87d140>
I think there might be some problems with init.py
我想这里面可能有问题
#2
0
Might work for you, just give it a try
也许对你有用,试试吧。
pip install pyexcel-xls
and then import this way
然后这样导入
>>> import pyexcel as pe
>>> import pyexcel.ext.xls
#1
1
I exactly don't know the reason of the error but I got a workaround for you. Try:
我完全不知道这个错误的原因,但我有一个解决办法。试一试:
>>> from pyexcel.core import *
>>> get_book_dict
>>> <function get_book_dict at 0x7fb8cc87d140>
I think there might be some problems with init.py
我想这里面可能有问题
#2
0
Might work for you, just give it a try
也许对你有用,试试吧。
pip install pyexcel-xls
and then import this way
然后这样导入
>>> import pyexcel as pe
>>> import pyexcel.ext.xls