草庐IT

MYLIB_FUNCTION_ATTRIBUTE

全部标签

python - graph.write_pdf ("iris.pdf") AttributeError : 'list' object has no attribute 'write_pdf'

我的代码是按照google的机器学习类的。两个代码是一样的。我不知道为什么会显示错误。可能是变量的类型是错误的。但是google的代码对我来说是一样的。谁有遇到过这个问题吗?这是错误[012][012]Traceback(mostrecentcalllast):File"/media/joyce/oreo/python/machine_learn/VisualizingADecisionTree.py",line34,ingraph.write_pdf("iris.pdf")AttributeError:'list'objecthasnoattribute'write_pdf'[Fin

python - 弹出错误: "[Errno 2] No such file or directory" when calling shell function

我有一些自定义命令。这行得通:subprocess.Popen(['python'],stdout=subprocess.PIPE)但如果我有自己的系统命令,例如deactivate,我会收到该错误Traceback(mostrecentcalllast):File"runner2.py",line21,inmain()File"runner2.py",line18,inmainsubprocess.Popen(['deactivate',],stdout=subprocess.PIPE)File"/usr/lib/python2.6/subprocess.py",line633,in

Python 调试器 : Stepping into a function that you have called interactively

Python很酷,但不幸的是,它的调试器不如perl-d。我在试验代码时经常做的一件事是从调试器中调用一个函数,然后单步执行该函数,如下所示:#NOTETHATTHISPROGRAMEXITSIMMEDIATELYWITHOUTCALLINGFOO()~>cat-n/tmp/show_perl.pl1#!/usr/local/bin/perl23subfoo{4print"hi\n";5print"bye\n";6}78exit0;~>perl-d/tmp/show_perl.plLoadingDBroutinesfromperl5db.plversion1.28Editorsuppo

python - 属性错误 : Module Pip has no attribute 'main'

我正在尝试为名为Zulip的开源项目构建pythonapi,但我一直遇到与下面的屏幕截图所示相同的问题。我正在运行python3,我的pip版本是10.0.0。有问题的文件是setup.py并且搞砸的代码是访问pip.main()属性以安装包时。现在,我知道这个构建应该会成功,因为它是一个开源项目,但我已经尝试了几个小时来解决关于pip.main()的依赖问题。任何帮助将不胜感激。 最佳答案 python3-mpipinstall--user--upgradepip==9.0.3pipissue:rollback

python - python的设计: why is assert a statement and not a function?

在Python中,assert是一个语句,而不是一个函数。这是一个深思熟虑的决定吗?让assert成为语句(和保留字)而不是函数有什么好处?根据thedocs,assertexpression1,expression2扩展为if__debug__:ifnotexpression1:raiseAssertionError(expression2)文档还说“当在编译时请求优化时,当前的代码生成器不会为断言语句发出代码。”在不知道细节的情况下,似乎需要一个特殊情况才能使这成为可能。但是,一种特殊情况也可用于优化对assert()函数的调用。如果assert是一个函数,你可以这样写:asser

python - Scikit Learn SVC decision_function 和 predict

我试图了解decision_function和predict之间的关系,它们是SVC的实例方法(http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html)。到目前为止,我已经收集到决策函数返回类之间的成对分数。我的印象是predict选择了最大化其成对分数的类,但我对此进行了测试并得到了不同的结果。这是我用来尝试理解两者之间关系的代码。首先,我生成了成对分数矩阵,然后我打印出了与clf.predict预测的类不同的最大成对分数的类。result=clf.decision_function(vector)[

python - 属性错误 : can't set attribute in python

这是我的代码N=namedtuple("N",['ind','set','v'])defsolve():items=[]stack=[]R=set(range(0,8))foriinrange(0,8):items.append(N(i,R,8))stack.append(N(0,R-set(range(0,1)),i))while(len(stack)>0):node=stack.pop()printnodeprintitems[node.ind]items[node.ind].v=node.v在最后一行中,我无法根据需要将items[node.ind].v值设置为node.v,并且

python - 为什么我收到 AttributeError : Object has no attribute?

已结束。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。此问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭2年前。本帖已编辑提交审核去年未能重新打开帖子:原始关闭原因未解决Improvethisquestion我有一个类(class)MyThread。在那,我有一个方法示例。我试图从同一个对象上下文中运行它。请看代码:classmyThread(threading.Thread):def__init__(self,threadID,name,cou

Python 属性错误 : 'module' object has no attribute 'SSL_ST_INIT'

我的一个Python脚本失败了:Traceback(mostrecentcalllast):File"./inspect_sheet.py",line21,inmain()File"./inspect_sheet.py",line12,inmainworkbook_name=workbook_name,File"./google_sheets.py",line56,in__init__self.login()File"./google_sheets.py",line46,inloginself.client=gspread.authorize(credentials)File"/usr

python - Django:模型表单 "object has no attribute ' clean_data'"

我正在尝试为我的一门类(class)制作搜索表单。表格的型号是:fromdjangoimportformsfromdjango.formsimportCharField,ModelMultipleChoiceField,ModelChoiceFieldfrombooks.modelsimportBook,Author,CategoryclassSearchForm(forms.ModelForm):authors=ModelMultipleChoiceField(queryset=Author.objects.all(),required=False)category=ModelCho