小编wDr*_*ter的帖子

python xlrd不支持的格式或损坏的文件.

我的代码:

import xlrd
wb = xlrd.open_workbook("Z:\\Data\\Locates\\3.8 locates.xls")
sh = wb.sheet_by_index(0)
print sh.cell(0,0).value
Run Code Online (Sandbox Code Playgroud)

错误:

Traceback (most recent call last):
File "Z:\Wilson\tradedStockStatus.py", line 18, in <module>
wb = xlrd.open_workbook("Z:\\Data\\Locates\\3.8 locates.xls")
File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 429, in open_workbook
biff_version = bk.getbof(XL_WORKBOOK_GLOBALS)
File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 1545, in getbof
bof_error('Expected BOF record; found %r' % self.mem[savpos:savpos+8])
File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 1539, in bof_error
raise XLRDError('Unsupported format, or corrupt file: ' + msg)
xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record;
found '<table r'"
Run Code Online (Sandbox Code Playgroud)

该文件似乎没有损坏或格式不同.任何有助于找到问题根源的事情都会很棒.

python excel xlrd

25
推荐指数
7
解决办法
8万
查看次数

无法使用pyodbc创建访问表

我正在尝试使用pyodbc使用python在MS Access DB中创建表,但是当我运行我的脚本时,没有创建表并且没有给出错误.我的代码:

#!/usr/bin/env python
import pyodbc

con = pyodbc.connect(r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=Z:\Data\Instruments\testDB.accdb; Provider=MSDASQL;')
cur = con.cursor()
string = "CREATE TABLE TestTable(symbol varchar(15), leverage double, shares integer, price double)"
cur.execute(string)
Run Code Online (Sandbox Code Playgroud)

可能有什么不对?

python ms-access pyodbc

17
推荐指数
1
解决办法
1万
查看次数

当我使用带有tkinter的update()时,我的Label会写另一行而不是重写相同的文本

当我使用tkinter调用update()方法而不是重写标签时,它只是在前一次调用下写入标签.我希望这可以重写前一行.

例如:

root=Tk()
while True:
    w=Label(root, text = (price, time))
    w.pack()
    root.update()
Run Code Online (Sandbox Code Playgroud)

python tkinter

6
推荐指数
2
解决办法
4万
查看次数

我在python中使用子进程拒绝了Errno 13 Permission

问题的关键是

ret=subprocess.call(shlex.split(cmd))

cmd = /usr/share/java -cp pig-hadoop-conf-Simpsons:lib/pig-0.8.1-cdh3u1-core.jar:lib/hadoop-core-0.20.2-cdh3u1.jar org.apache.pig.Main -param func=cat -param from =foo.txt -x mapreduce fsFunc.pig 
Run Code Online (Sandbox Code Playgroud)

错误是.

File "./run_pig.py", line 157, in process
    ret=subprocess.call(shlex.split(cmd))
File "/usr/lib/python2.7/subprocess.py", line 493, in call
  return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
  errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
  raise child_exception
OSError: [Errno 13] Permission denied
Run Code Online (Sandbox Code Playgroud)

如果需要更多信息,请告诉我.任何帮助表示赞赏.谢谢.

python error-handling bash hadoop apache-pig

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×4

apache-pig ×1

bash ×1

error-handling ×1

excel ×1

hadoop ×1

ms-access ×1

pyodbc ×1

tkinter ×1

xlrd ×1