草庐IT

must_raise

全部标签

python - 值错误 ("color kwarg must have one color per dataset")?

我只是简单地将数据保存到文件中并读出它们,然后绘制直方图。但是,尽管我实际上没有对原始代码进行任何更改,但似乎出现了这个错误。谁能告诉我怎么了?非常感谢。这是hist()的代码f_120=plt.figure(1)plt.hist(tfirst_list,bins=6000000,normed=True,histtype="step",cumulative=True,color='g',label='firstanswer')plt.axvline(x=30,ymin=0,ymax=1,color='r',linestyle='--',label='30min')plt.axvline

python - 使用 python 运行 bash 脚本 - TypeError : bufsize must be an integer

我正在尝试编写python文件,即python中的wxtractar文件。据我所知,subprocess是完成此任务的合适工具。我写了下面的代码:fromsubprocessimportcalldeftarfile(path):call(["tar"],path)if__name__=="__main__":tarfile("/root/tryit/output.tar")当输出为tar文件时,位于/root/tryit/。当我运行它时,我收到以下消息:TypeError:bufsizemustbeaninteger我可以通过这个工具使用tar命令吗? 最佳

python - 您的 "must-have"金融 Python 包是什么?

随着最近SECproposal要求大多数Assets支持证券发行人提交一个python计算机程序来记录交易的资金流(或瀑布)规定,我认为现在是时候问你认为金融“必备”Python包是什么了。PS:除了在这里回答,还请考虑回答thissurvey.更新:调查结果here. 最佳答案 http://code.google.com/p/pandas/也是量化金融背景下开发的。我想那是通常的嫌疑人:NumPy科学努力matplotlib...对于我的量化开发,我通常以pythonxy(http://www.pythonxy.com/)作为基

python: raise child_exception, OSError: [Errno 2] 没有那个文件或目录

我使用subprocess.popen()函数在python中执行命令,如下所示:omp_cmd='cat%s|omp-h%s-u%s-w%s-p%s-X-'%(temp_xml,self.host_IP,self.username,self.password,self.port)xmlResult=Popen(omp_cmd,stdout=PIPE,stderr=STDOUT)在shell中它运行良好没有错误,但在python中我得到:File"/home/project/vrm/apps/audit/models.py",line148,insendOMPxmlResult=Pop

python - 如何切片 2D Python 数组? : "TypeError: list indices must be integers, not tuple" 失败

我在numpy模块中有一个二维数组,如下所示:data=array([[1,2,3],[4,5,6],[7,8,9]])我想得到这个数组的一部分,它只包含元素的某些列。例如,我可能需要第0列和第2列:data=[[1,3],[4,6],[7,9]]最符合Pythonic的方法是什么?(请不要循环)我认为这会起作用:newArray=data[:,[0,2]]但结果是:TypeError:listindicesmustbeintegers,nottuple 最佳答案 错误明确地说:数据不是一个numpy数组,而是一个列表列表。首先尝试

python - OpenCV ORB 描述符 : TypeError: Incorrect type of self (must be 'Feature2D' or its derivative)

我遵循了这个简单的OpenCVFeatureMatchingexample正是:importcv2img=cv2.imread('box.png',0)#queryImageorb=cv2.ORB()#InitiateORBdetector#findthekeypointsanddescriptorswithORBkp1,des1=orb.detectAndCompute(img,None)出现以下错误:TypeError:Incorrecttypeofself(mustbe'Feature2D'oritsderivative)我正在使用OpenCV3.3.1

python - Json 转储字典抛出 TypeError : keys must be a string

我正在尝试使用json.dumps将以下dict转换为JSON:{'post_engaged':36,'post_impressions':491,'post_story':23,'comment_count':6,'created_time':'03:02AM,Sep30,2012','message':'SpecialitiesofShaktisandPandavas.\nWhilehavingpower,whythereisn\\u2019t',:'471662059541196','status_type':'status','likes_count':22}{'post_en

python 3 : super() raises TypeError unexpectedly

来自Java,我在理解继承、抽象类、静态方法和Python中OO编程的类似概念时遇到了一些困难。我有一个表达式树类的实现,给定(简化)#GenericnodeclassclassNode(ABC):@abstractmethoddefto_expr(self):pass@staticmethoddefbracket_complex(child):s=child.to_expr()returnsifisinstance(child,Leaf)orisinstance(child,UnaryOpNode)else"("+s+")"#Leafclass-usedforvaluesandvar

python - 语法错误 : Generator expression must be parenthesized

我刚刚安装了django,安装后我创建了一个django项目,并试图通过命令运行django服务器:pythonmanage.pyrunserver在那之后我得到的错误是:SyntaxError:生成器表达式必须加括号 最佳答案 TL;DR:将Django升级到1.11.17+或2.0+版本此错误isaknownincompatibility与Pythonissue#32012有关.基于Django1.11.16及以下版本的项目在使用Python3.7启动时将引发此异常。此问题的补丁hasbeenmergedintoDjango2.

python - RuntimeError : 'list' must be None or a list, not <class 'str' > while trying to start celery worker

我正在尝试在关注FirstStepsWithDjango时添加celery任务但我收到以下错误:Traceback(mostrecentcalllast):File"/Users/amrullahzunzunia/virtualenvs/flyrobe_new/bin/celery",line11,insys.exit(main())File"/Users/amrullahzunzunia/virtualenvs/flyrobe_new/lib/python3.5/site-packages/celery/__main__.py",line30,inmainmain()File"/Us