版本:python 3.8 xlrd 1.2.1
import xlrd
worksheet = xlrd.open_workbook('测试数据写入.xlsx')
报错:
File "N:/untitled/临时/41.py", line 16, in
worksheet = xlrd.open_workbook('测试数据写入.xlsx') # 打开excel文件
File "D:\Python\lib\site-packages\xlrd__init__.py", line 151, in open_workbook
bk = book.open_workbook_xls(
File "D:\Python\lib\site-packages\xlrd\book.py", line 75, in open_workbook_xls
t0 = time.clock()
AttributeError: module 'time' has no attribute 'clock'
book.py:
t0 = time.clock()
if TOGGLE_GC:
orig_gc_enabled = gc.isenabled()
if orig_gc_enabled:
gc.disable()
bk = Book()
__inlt__.py
bk = book.open_workbook_xls(
filename=filename,
logfile=logfile,
verbosity=verbosity,
use_mmap=use_mmap,
file_contents=file_contents,
encoding_override=encoding_override,
formatting_info=formatting_info,
on_demand=on_demand,
ragged_rows=ragged_rows,
extract_formulas=extract_formulas,
)
return bk
哪位大神看下啥原因 怎么办
python3.8已经不支持time.clock()了,可以用time.perf_counter()替换,望采纳,谢谢!
在Python 3.8中,time.clock()
删除了,因为源代码改起来很难,可以在引入前加入一段猴子补丁:
import time
time.clock=time.perf_counter
time模块没有clock()这个方法
题主你好,在Python3.8中,已经移除了 clock() 方法,
你可以使用 time.perf_counter() 或 time.process_time() 方法替代。
t0 = time.perf_counter()
print(t0)
t1 = time.process_time()
print(t1)
程序开头加上
import time