|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
大佬们求助一下 为什么这段代码报错了 没生成新excel 谢谢大佬
import xlwt
#write
new_workbook = xlwt.Workbook()
worksheet = new_workbook.add_sheet('test_sheet')
worksheet.write(0,0,'test')
new_workbook.save('d:/test.xls')
报错原因
Traceback (most recent call last):
File "c:\Users\11573\python练手\excel - 副本.py", line 1, in <module>
import xlwt
File "C:\Python37\lib\site-packages\xlwt\__init__.py", line 4, in <module>
from .Worksheet import Worksheet
File "C:\Python37\lib\site-packages\xlwt\Worksheet.py", line 41, in <module>
import tempfile
File "C:\Python37\lib\tempfile.py", line 45, in <module>
from random import Random as _Random
File "c:\Users\11573\python练手\random.py", line 3, in <module>
secret=random.randint(1,100)
AttributeError: module 'random' has no attribute 'randint'
c:\Users\11573\python练手\random.py
这个文件造成的,为了避免出错,自己写的代码尽量不要与python的模块重名
|
|