问题1:pywintypes.com_error: (-2147352573, '找不到成员。', None, None)
解决办法:机子上同时安装了微软office和金山的wps,造成了冲突,将wps卸载掉后正常
问题2:运行时候,在家里面电脑上运行到rows = sht_1.api.UsedRange.Rows.count 这行后就卡死,但是在单位上电脑上运行就ok,都是同样配置的虚拟机。都有把人搞崩溃了。
解决办法:
发现count第一个字母小写了,将第一个字母大写Count,问题解决
rows = sht_1.api.UsedRange.Rows.Count
问题2:写入xls时,报错。ValueError: could not convert string to float: 'MRM、MRU'
问题描述:
在写入xls时候,突然报上面错误,看代码,没有错了
with open('doctor/2.项目.txt', 'r', encoding='ANSI') as fd:
for text in fd.readlines():
a = text.split(',')[0]
#print(a)
b = text.split(',')[1]
c = int(float(text.split(',')[2]))
d = int(float(text.split(',')[3]))
sheet.write(n, 0, a) # 往表格里写入
sheet.write(n, 1, b) # 往表格里写入
sheet.write(n, 2, c) # 往表格里写入
sheet.write(n, 3, d) # 往表格里写入
解决方法:
仔细分析,发现数据里面有MRM前面使用了“,”符合,就是她了,将前面的","号给删掉,运行正常