Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我无法使函数 getattr 工作。这是我的代码:
print ConfigConsModel()._meta.get_all_field_names() #['codesectrepmodel', 'configCons', 'id'] modelInstance=ConfigConsModel() newAttrName1=getattr(modelInstance, "configCons") print newAttrName1 #empty -> PB
怎么了?
modelInstance=ConfigConsModel()
这初始化modelInstance为ConfigConsModel类的新(空)实例
modelInstance
ConfigConsModel
newAttrName1=getattr(modelInstance, "configCons")
这条线相当于
newAttrName1=modelInstance.configCons
它没有获取属性的名称,而是获取它的值。这当然是空的。
在我的网站上,我有一个<我想删除的标志,它显示在桌子之前和 YouTube 视频之后。
<
问题是,该字符没有出现在index.html文件中。为了确定,我已经在三个编辑器中检查过它。我不知道它是从哪里来的。
index.html
如果您在 Firefox 中删除该表,它会消失