搜索到与相关的文章
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 2016

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 2016

Python

Spark学习实例(Python):RDD、DataFrame、DataSet

在学习转换之前先了解以下它们的基本概念RDD:弹性分布式数据集,是一个只读分区集合DataFrame:以命名列方式组织的分布式数据集,概念上和关系型数据库的一张表一样DataSet:分布式数据集合,Python暂时不支持了解了基本的概念之后,接下来我们通过代码编写三种数据集的形成RDD的形成frompyspark.sqlimportSparkSessionif__name__=='__main__':spark=SparkSession\.builder\

系统 2019-09-27 17:52:31 2016

Python

Python常用的日期时间处理方法示例

#-*-coding:utf-8-*-importdatetime#给定日期向后N天的日期defdateadd_day(days):d1=datetime.datetime.now()d3=d1+datetime.timedelta(days)returnd3#昨天defgetYesterday():today=datetime.date.today()oneday=datetime.timedelta(days=1)yesterday=today-one

系统 2019-09-27 17:52:22 2016

Python

Python适配器模式代码实现解析

Python适配器模式,代码,思考等#-*-coding:utf-8-*-#author:baoshanclassComputer:def__init__(self,name):self.name=namedef__str__(self):return'the{}computer'.format(self.name)defexecute(self):return'executesaprogram'classSynthesizer:def__init__(s

系统 2019-09-27 17:52:07 2016

Python

[python整理]@staticmethod和@classmethod的作用

前言知识在于细节,整理很重要。在python中,有3类方法:1)静态方法(staticmethod)2)类方法(classmethod)3)实例方法其中静态方法和类方法是不需要进行实例就可以直接调用,语法格式:类名.方法名具体举个例子说明deffunc(x):print("hello,我是常用方法")classFun:deffunc1(self,x):print("hello,我是类中方法",x,self)@classmethoddeffunc2(cls,

系统 2019-09-27 17:51:55 2016

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 2016

Python

浅析Python装饰器以及装饰器模式

漫谈如果作为一个Python入门,不了解Python装饰器也没什么,但是如果作为一个中级Python开发人员,如果再不对python装饰器熟稔于心的话,那么可能并没有量变积累到质变。我以前也看过很多讲python装饰器的文章,但是都是看了就忘。一方面是没有做太多的练习,二是对它的领会不是很深。希望引以为戒!!!郑传装饰模式如果你了解Java,你肯定听过装饰器模式。在面向对象中,装饰模式指:动态地给一个对象添加一些额外的职责。就增加一些功能来说,装饰模式比生

系统 2019-09-27 17:51:05 2016

Python

10种经典机器学习算法——Python版

klearnpythonAPILinearRegressionfromsklearn.linear_modelimportLinearRegression#线性回归#module=LinearRegression()module.fit(x,y)module.score(x,y)module.predict(test)LogisticRegressionfromsklearn.linear_modelimportLogisticRegression#逻辑回

系统 2019-09-27 17:51:04 2016

Python

python实现简单成绩录入系统

学了一个多月的python,做了一个小程序:python实现简单成绩录入系统,实验一下menu部分fromtkinterimport*#这是一个python模块,python3中都有importtkinter.messagebox#这也是一个模块fromfile_readimportreadfromfile_writeimportwriteclassstudent_main():#定义一个学生类def__init__(self):self.name=''s

系统 2019-09-27 17:50:34 2016