09 2022 档案
摘要:类里面定义的叫方法。类外面定义的叫函数 静态方法:不允许加self 类方法:必须加cls 实例方法:必须加self
阅读全文
摘要:想把字符型转成整型时报错,ValueError: invalid literal for int() with base 10。 在不确定这个字符串是整形还是浮点数得情况下,用float()比较好,这样可以避免以上错误。 a= '128.0' f = float(verifyBase) # 转为浮点
阅读全文
摘要:def closesoft(): print('''挂载程序关闭中…… ''') import win32com import win32com.client wc = win32com.client.constants try: wps = win32com.client.gencache.Ens
阅读全文
摘要:背景 卸载一直使用的wps,并且重新安装后,电脑python3使用pywin32操作excel文件就报错:AttributeError:module‘win32com.gen_py has no attribute ‘CLSIDToClassMap‘ 报错信息如下: Traceback (most
阅读全文
摘要:# 设置已用范围的单元格边框 def setBorderWeight(sheet): r = sheet.usedRange # 获取已使用范围的最大行数 r.Borders.Weight = 2 # 设置区域的边框粗细 cell_range = Sheet.Cells(8, 6) cell_ran
阅读全文
摘要:n = sheet.Shapes for i in n: i.ScaleHeight(2, True) i.Delete() Shape.Delete 方法 (Excel) 删除对象。 语法 表达式。删除 表达式 一个代表 Shape 对象的 变量。 Shape.Delete 方法 (Excel)
阅读全文
摘要:excel = Dispatch("ket.Application") # 启动wps excel 应用。Microsoft excel用Excel.Application excel.Visible = False file = r'C:\Users\meiya\PycharmProjects\e
阅读全文
摘要:data = ['a','b'] for index, i in enumerate(data): c = sheet.Cells(38 + index, 'A') c.Value = i c.HorizontalAlignment = -4131 # 水平左对齐 c.VerticalAlignme
阅读全文
摘要:a = sheet.Range("A2")pic = sheet.Pictures().Insert(pngfile)r = pic.ShapeRangeh = 450scale = r.Width / r.Height # 等比例缩放尺度。w = int(h * scale) # 获得相应等比例的
阅读全文