草庐IT

out_queue

全部标签

python - 值错误 : day is out of range for month

我想将字符串从数据帧转换为日期时间。dfx=df.ix[:,'a']dfx=pd.to_datetime(dfx)但它给出了以下错误:ValueError:dayisoutofrangeformonth有人可以帮忙吗? 最佳答案 也许可以帮助将参数dayfirst=True添加到to_datetime,如果日期时间的格式是30-01-2016:dfx=df.ix[:,'a']dfx=pd.to_datetime(dfx,dayfirst=True)更通用的是使用参数format使用errors='coerce'将值替换为其他form

python /dpkt : Find out if packet is a tcp packet or a udp packet ,

我有一个python脚本,它使用dpkt捕获以太网上的数据包,但我如何区分哪些数据包是tcp,哪些是udp。最终,我希望获得在时间间隔内建立的每个tcp连接的数据包列表。我的代码是:importdpktimportpcapycap=pcap.open_live('eth0',100000,1,0)(header,payload)=cap.next()whileheader:eth=dpkt.ethernet.Ethernet(str(payload))ip=eth.datatcp=ip.data#ineedtoknowwhetheritisatcporaudppackethere!!!

python - multiprocessing.Pipe 比 multiprocessing.Queue 还要慢?

我尝试通过multiprocessing包中的Queue对Pipe的速度进行基准测试。我认为Pipe会更快,因为Queue在内部使用Pipe。奇怪的是,Pipe在发送大型numpy数组时比Queue慢。我在这里缺少什么?管道:importsysimporttimefrommultiprocessingimportProcess,PipeimportnumpyasnpNUM=1000defworker(conn):fortask_nbrinrange(NUM):conn.send(np.random.rand(400,400,3))sys.exit(1)defmain():parent_

python - 索引错误 : index 1 is out of bounds for axis 0 with size 1/ForwardEuler

我正在对一阶微分方程组的x(t)进行数值求解。该系统是:dy/dt=(C)\*[(-K\*x)+M*A]我已经实现了正向欧拉方法来解决这个问题,如下所示:这是我的代码:importmatplotlibimportnumpyasnpfromnumpyimport*fromnumpyimportlinspacefrommatplotlibimportpyplotaspltC=3K=5M=2A=5#------------------------------------------------------------------------------defeuler(f,x0,t):n=l

python - sys.argv[1], IndexError : list index out of range

这个问题在这里已经有了答案:Whatdoes"sys.argv[1]"mean?(9个回答)关闭4年前。我对以下Python代码部分有疑问:#Open/Createtheoutputfilewithopen(sys.argv[1]+'/Concatenated.csv','w+')asoutfile:try:withopen(sys.argv[1]+'/MatrixHeader.csv')asheaderfile:forlineinheaderfile:outfile.write(line+'\n')except:print'NoHeaderFile'具体报错如下:Traceback(

python - 我是否需要将 multiprocessing.Queue 实例变量显式传递给在实例方法上执行的子进程?

关于使用Python的multiprocessing模块,我有几个基本问​​题:classSomeparallelworkerclass(object):def__init__(self):self.num_workers=4self.work_queue=multiprocessing.JoinableQueue()self.result_queue=multiprocessing.JoinableQueue()defsomeparallellazymethod(self):p=multiprocessing.Process(target=self.worktobedone).sta

python - 为什么Python的Queue在qsize()中返回一个大概的大小?

在docqsize()它说:返回队列的近似大小。为什么它不能只返回这个队列的确切大小?我知道队列可能会被多个线程访问,但在我调用该函数的那一刻,我认为它仍然可以返回那一刻的确切大小。 最佳答案 正是因为有其他线程在访问它。当您尝试使用从qsize()返回的大小时,队列可能已经改变。如果文档阅读这样的内容会更好:Returnsthesizeofthequeue.Notethatinamulti-threadedenvironment,thesizecanchangeatanytime,makingthisonlyanapproxima

python - 为什么 logged_out.html 没有覆盖 Django 注册?

我正在使用内置的Django登录和注销。在我的Project/urls.py中,我添加了用于登录和注销的url。fromdjango.conf.urlsimportinclude,urlfromaccountimportviewsfromdjango.contrib.authimportviewsasauth_viewsfromdjango.contribimportadminurlpatterns=[url(r'^admin/',include(admin.site.urls)),url(r'^$',views.index,name='Index'),url(r'^accounts/

python - 如何清除 multiprocessing.Queue?

我只想知道如何像Python中的queue.Queue一样清除multiprocessing.Queue:>>>importqueue>>>queue.Queue().clear()Traceback(mostrecentcalllast):File"",line1,inAttributeError:'Queue'objecthasnoattribute'clear'>>>queue.Queue().queue.clear()>>>importmultiprocessing>>>multiprocessing.Queue().clear()Traceback(mostrecentcal

python - matplotlib 条形图 : space out bars

我如何使用matplotlib条形图增加每个条形之间的空间,因为它们一直将自己塞到中心。(这是目前的样子)importmatplotlib.pyplotaspltimportmatplotlib.datesasmdatesdefww(self):#wrongwordstextfilewithopen("wrongWords.txt")asfile:array1=[]array2=[]forelementinfile:array1.append(element)x=array1[0]s=x.replace(')(','),(')#removesthequotemarksfromcsvfi