搜索到与相关的文章
Python

Python读写Excel文件方法介绍

一、读取excel这里介绍一个不错的包xlrs,可以工作在任何平台。这也就意味着你可以在Linux下读取Excel文件。首先,打开workbook;复制代码代码如下:importxlrdwb=xlrd.open_workbook('myworkbook.xls')检查表单名字:复制代码代码如下:wb.sheet_names()得到第一张表单,两种方式:索引和名字复制代码代码如下:sh=wb.sheet_by_index(0)sh=wb.sheet_by_n

系统 2019-09-27 17:54:06 1980

Python

Python 常见函数的基本使用(边学边更)

最近在学习Python,所谓好记性不如烂笔头故借这次学习机会做个笔记,方便今后快速再学习。以下是常见函数的使用说明:range函数该函数用于创建数列,根据参数个数不同对应不同的用法进行说明(1)range(a,b,c)三个参数时,表示创建一个从a~b-1的数组,每c个数取一个值。当c=1时,可省略c,即用法等同于(2)(2)range(x,y)两个参数时,表示创建一个从a~b-1的数组,一共b-a个元素。当x=0时,可省略y,用法等同于(1)(3)rang

系统 2019-09-27 17:53:51 1980

Python

leetcode 53. Maximum Subarray 解法 python

一.问题描述Givenanintegerarraynums,findthecontiguoussubarray(containingatleastonenumber)whichhasthelargestsumandreturnitssum.Example:Input:[-2,1,-3,4,-1,2,1,-5,4],Output:6Explanation:[4,-1,2,1]hasthelargestsum=6.Followup:Ifyouhavefigur

系统 2019-09-27 17:53:31 1980

Python

python驱动

阅读更多1,下载pip安装包pip-19.1.1.tar.gz;2,解压缩后出现setup.py文件,然后在目录中通过Shift+右击,点击在此处打开命令窗口,通过pythonsetup.pyinstall,进行安装;3,安装后,通过cmd窗口中,输入piplist,查看命令是否起作用;4,使用pipinstall-Upip,对pip进行升级;5,使用pipinstallpsycopg2,安装postgresql数据驱动;注意:1,python不要装在c盘

系统 2019-09-27 17:53:05 1980

Python

python检测RabbitMQ的状态是否正常的代码

将做工程过程中重要的一些代码段收藏起来,下面代码段是关于python检测RabbitMQ的状态是否正常的代码。importsocketdefcheck_aliveness(ip,port):sk=socket.socket(socket.AF_INET,socket.SOCK_STREAM)sk.settimeout(1)try:sk.connect((ip,port))print'serviceisOK!'returnTrueexceptExceptio

系统 2019-09-27 17:52:41 1980

Python

Python+matplotlib实现填充螺旋实例

填充螺旋演示结果:实例代码:importmatplotlib.pyplotaspltimportnumpyasnptheta=np.arange(0,8*np.pi,0.1)a=1b=.2fordtinnp.arange(0,2*np.pi,np.pi/2.0):x=a*np.cos(theta+dt)*np.exp(b*theta)y=a*np.sin(theta+dt)*np.exp(b*theta)dt=dt+np.pi/4.0x2=a*np.cos

系统 2019-09-27 17:52:35 1980

Python

python学习笔记——小插曲

作为eclipse的忠实粉丝,我自然乐意用eclipse来编写。于是捣鼓了一小会儿就搞好了。但是我运行的第一个程序出现了一个很奇怪的问题:SyntaxError:(unicodeerror)‘utf-8’codeccan’tdecodebyte0xceinposition16:invalidcontinuationbyte我隐约的看到了utf-8,知道了肯定是编码的问题,可是我寻思我没有写汉字呀原来是自动生成的日期中有中文。删掉就好了。但是如果我们真的需要

系统 2019-09-27 17:52:01 1980

Python

python笔记2

阅读更多操作列表#列表循环for循环(for**in**)1.注意使用for循环时print前要缩进cats=["alice","clear","dell",'moon']forcatincats:print(cat)#可在for循环中执行更多操作#2.不使用for循环时,切记print能缩进cats=["alice","clear","dell",'moon']forcatincats:print(cat)print("theyaresocute")#在

系统 2019-09-27 17:51:30 1980

Python

使用python serial 获取所有的串口名称的实例

如下所示:#!/usr/bin/envpython#-*-coding:utf-8-*importserialimportserial.tools.list_portsport_list=list(serial.tools.list_ports.comports())iflen(port_list)<=0:print"TheSerialportcan'tfind!"else:port_list_0=list(port_list[0])port_serial

系统 2019-09-27 17:50:57 1980

Python

Python 類和對象 Class vs Object

類別定義class類別名:例如:>>>classPoint:...x=0.0...y=0.01.宣告>>>p1=Point()>>>p1.x,p1.y(0.0,0.0)2.賦値>>>p1.x=5.0>>>p1.y=6.0>>>p1.x,p1.y(5.0,6.0)3.位址指向>>>p1<__main__.Pointobjectat0x00000000021B22E8>>>>id(p1.x)30060832>>>id(p1.y)300608084.別名Alia

系统 2019-09-27 17:50:30 1980