1
其实,我想写如何运用自己的方法参数在Python
def w_cell(self, r, c, val, style=XLS.get_cell_stlye(self))
但它不能,并让我
NameError错误:名称“自我”是没有定义
如何在参数中设置默认样式,而不是在函数中。
感谢
class XLS():
def get_cell_stlye(self):
return xlwt.easyxf("alignment: horizontal center,\
vertical center, wrap true ;")
class TestCGI(object, XLS):
def w_cell(self, r, c, val, style='null'):
if style == 'null':
style=XLS.get_cell_stlye(self)
self.sht.write(r, c, val, style)
在这种情况下,我会是'如果风格不None' - 你的版本也将拿起'style = 0',这可能有意义,也可能没有意义。 – mgilson