前言知识在于细节,整理很重要。在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 1942
前言今天就简单的对日志做个封装,实际工作中直接拿去用吧方法1"""------------------------------------@Time:2019/5/228:12@Auth:linux超@File:logfile.py@IDE:PyCharm@Motto:Realwarriors,daretofacethebleakwarning,daretofacetheincisiveerror!-----------------------------
系统 2019-09-27 17:51:39 1942
每天换一个壁纸,每天好心情。#-*-coding:UTF-8-*-from__future__importunicode_literalsimportImageimportdatetimeimportwin32gui,win32con,win32apiimportrefromHttpWrapperimportSendRequestStoreFolder="c:\\dayImage"defsetWallpaperFromBMP(imagepath):k=wi
系统 2019-09-27 17:51:14 1942
漫谈如果作为一个Python入门,不了解Python装饰器也没什么,但是如果作为一个中级Python开发人员,如果再不对python装饰器熟稔于心的话,那么可能并没有量变积累到质变。我以前也看过很多讲python装饰器的文章,但是都是看了就忘。一方面是没有做太多的练习,二是对它的领会不是很深。希望引以为戒!!!郑传装饰模式如果你了解Java,你肯定听过装饰器模式。在面向对象中,装饰模式指:动态地给一个对象添加一些额外的职责。就增加一些功能来说,装饰模式比生
系统 2019-09-27 17:51:05 1942
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 1942
如下所示:#!/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 1942
類別定義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 1942
Python3注释确保对模块,函数,方法和行内注释使用正确的风格Python中的注释有单行注释和多行注释:Python中单行注释以#开头,例如::#这是一个注释print("Hello,World!")多行注释用三个单引号'''或者三个双引号"""将注释括起来,例如:1、单引号(''')#!/usr/bin/python3'''这是多行注释,用三个单引号这是多行注释,用三个单引号这是多行注释,用三个单引号'''print("Hello,World!")2、
系统 2019-09-27 17:49:52 1942
python中with可以明显改进代码友好度,比如:复制代码代码如下:withopen('a.txt')asf:printf.readlines()为了我们自己的类也可以使用with,只要给这个类增加两个函数__enter__,__exit__即可:复制代码代码如下:>>>classA:def__enter__(self):print'inenter'def__exit__(self,e_t,e_v,t_b):print'inexit'>>>withA()
系统 2019-09-27 17:49:50 1942
Apache配置文件:httpd.conf文件#指定Apache的安装路径,此选项参数值在安装Apache时系统会自动把Apache的路径写入。ServerRoot"/www/server/apache"#Listen主要侦听web服务端口状态,默认为:80,即侦听所有的地址的80端口,注意这里也可以写成IP地址的侦听形式,不写即默认的地址:0.0.0.0Listen106.15.88.162:80Listen80#指定Apache运行用户配置Userww
系统 2019-09-27 17:49:45 1942