草庐IT

ARGUMENT

全部标签

python - TypeError : int() argument must be a string or a number, 不是 'datetime.datetime'

我已将App12/models.py模块制作为:fromdjango.dbimportmodelsclassQuestion(models.Model):ques_text=models.CharField(max_length=300)pub_date=models.DateTimeField('Publisheddate')def__str__(self):returnself.ques_textclassChoice(models.Model):#question=models.ForeignKey(Question)choice_text=models.CharField(ma

python - 子进程.Popen : how to pass a list as argument

我只需要有关如何正确做事的提示。假设我有一个名为script.py的脚本,它使用名称列表作为参数["name1"、"name2"等]。我想使用subprocess模块从另一个脚本调用这个脚本。所以我想做的是:myList=["name1","name2","name3"]subprocess.Popen(["python","script.py",myList])当然这不起作用,因为subprocess.Popen方法需要一个字符串列表作为参数。所以我考虑执行以下操作:subprocess.Popen(["python","script.py",str(myList)])现在进程开始了

python - django 类型错误 : get() got multiple values for keyword argument 'invoice_id'

我对python和django比较陌生,我有以下restapiView,classInvoiceDownloadApiView(RetrieveAPIView):"""ThisAPIviewwillretrieveandsendTermsandConditionfilefordownload"""permission_classes=(IsAuthenticated,)defget(self,invoice_id,*args,**kwargs):ifself.request.user.is_authenticated():try:invoice=InvoiceService(user=

python - 默认字典 : first argument must be callable or None

我运行了以下代码:fromcollectionsimportdefaultdictlst=list(range(0,5))d=defaultdict(lst)我得到了这个错误:TypeError:firstargumentmustbecallableorNone请帮忙 最佳答案 对于defaultdict,默认值通常不是真正的值,它是一个工厂:一个方法产生新的值(value)。您可以使用生成列表的lambda表达式解决此问题:lst=lambda:list(range(0,5))d=defaultdict(lst)这也是一个好主意,

python - Jupyter 笔记本不保存 : '_xsrf' argument missing from post

我已经在jupyternotebooks上运行一个脚本大约26小时了;我并没有真正使用我的电脑做任何其他事情,但它需要运行这个需要大约30小时才能完成的程序。大约21小时后,它停止保存,我的终端有这个:403PUT/api/contents/[file.ipynb](::1):'_xsrf'argumentmissingfromPOST其中[file.ipynb]是我的jupyternotebook的位置。它还说:'_xsrf'argumentmissingfrompost再次出现在笔记本的右上角。程序仍在运行,我不想重启jupyternotebook而不得不再次运行程序,因为我有截止

python 3.5 -> 3.6 Tablib TypeError : cell() missing 1 required positional argument: 'column'

从python3.5迁移到3.6,我的单元测试揭示了django-import-export和tablib的问题:TypeError:cell()missing1requiredpositionalargument:'column'File"/lib/python3.6/site-packages/tablib/formats/_xlsx.py",line122,indset_sheetcell=ws.cell('%s%s'%(col_idx,row_number))TypeError:cell()missing1requiredpositionalargument:'column't

python - TypeError : first argument must be an iterable of pandas objects, 你传递了一个类型为 "DataFrame"的对象

我有一个大数据框,我尝试将其拆分并在concat之后拆分。我用df2=pd.read_csv('et_users.csv',header=None,names=names2,chunksize=100000)forchunkindf2:chunk['ID']=chunk.ID.map(rep.set_index('member_id')['panel_mm_id'])df2=pd.concat(chunk,ignore_index=True)但是返回错误TypeError:firstargumentmustbeaniterableofpandasobjects,youpassedano

python - 类型错误 : float() argument must be a string or a number in Django distance

我试图从我的模板中获取kmdistance的值,但当我查看页面时它返回错误。这是views.pydefdisplay_maps(request):#basesforcityproperpnt=ButuanMaps.objects.get(clandpin='162-03-0001-017-33').geom#landproperty__sownerid__id=5isforgovernmentuserkmdistance=request.GET.get("kmtocity",None)mysection=(request.GET.get("mysection",None))query_

python - 类型错误 : bad argument type for built-in operation

我收到错误TypeError:badargumenttypeforbuilt-inoperation。我写了importosimportcv2frompathlibimportPathpath=Path(__file__).parentpath/="../../img_folder"forfinpath.iterdir():print(f)img=cv2.imread(f)在img=cv2.imread(f)中,出现错误。这是Python错误还是目录错误错误?在print(f)中,我认为可以获取正确的目录。我应该如何解决这个问题? 最佳答案

python - Pandas drop_duplicates - TypeError : type object argument after * must be a sequence, 未映射

我更新了我的问题以提供更清晰的示例。是否可以使用Pandas中的drop_duplicates方法根据值包含列表的列ID删除重复行。考虑由列表中的两个项目组成的“三”列。有没有一种方法可以删除重复的行而不是反复进行(这是我目前的解决方法)。我通过提供以下示例概述了我的问题:importpandasaspddata=[{'one':50,'two':'5:00','three':'february'},{'one':25,'two':'6:00','three':['february','january']},{'one':25,'two':'6:00','three':['februa