局部变量什么是局部变量通俗定义:函数内部定义的变量就叫局部变量。话不多说,代码如下:deftest1():a=300#定义一个局部变量a,并初始化300print("--test1--修改前:a=%s"%a)a=200#给变量a重新赋值200print("--test1--修改后:a=%s"%a)deftest2():a=400#定义另一个局部变量a,并初始化400print("--test2--修改后:a=%s"%a)#分别调用函数test1,test2
系统 2019-09-27 17:56:01 2303
python常用导入函数及其他操作备忘录python常用导入函数解压缩zip并读取csv文件查看缺失值权重系数取绝对值后排序(查看特征权重重要度)python常用导入函数fromIPython.displayimportdisplayimportnumpyasnpimportpandasaspdfrompandasimportSeries,DataFramefromPILimportImageimportmatplotlib.pyplotasplt%mat
系统 2019-09-27 17:55:18 2303
使用pyinstaller可以把.py文件打包为.exe可执行文件,命令为:pyinstallerhello.py打包后有两个文件夹,一个是dist,另外一个是build,可执行文件在dist文件夹里面,但是会有许多依赖是独立文件存在pyinstaller-Fhello.py使用-F参数后,打包的可执行文件是一个整体,只有一个.exe文件。获取文件路径的方式有四种,可以在打包成exe文件后,获取.exe文件的当前路径importsysimportospri
系统 2019-09-27 17:54:31 2303
不完美的Python自从各类Python大火,感觉天上地下哪儿都有Python的一席之地,Python功夫好啊…但python有些细节上缺少其他语言的便利。今天我们就来举几个例子。跳出外层循环大家都知道,在Java中存在标签的概念,当我们存在多层循环时,Java可以使用标签控制指定的循环层。举个小栗子:publicclassOuterLoop{publicstaticvoidmain(String[]args){outer:for(inti=0;i<5;i
系统 2019-09-27 17:54:10 2303
python的base64.decodestring方法做base64解码时报错:复制代码代码如下:Traceback(mostrecentcalllast):File"/export/www/outofmemory.cn/controllers/user.py",line136,indecryptPasswordencryptPwd=base64.b64decode(encryptPwd)File"/usr/lib/python2.7/base64.py
系统 2019-09-27 17:53:16 2303
InstallingOpenCVinUbuntuforPython3byWK·PublishedMarch2,2016·UpdatedMarch3,2017InstallingOpenCVinlinuxforPython3isnotthatstraightforward,sointhistutorial,we’llgothroughthestepsonhowdowedoit.We’llbeusinga64bitUbuntu16.04system,andPy
系统 2019-09-27 17:53:02 2303
Python正则表达式匹配数字电话号码:\d{3}-\d{8}|\d{4}-\d{7}QQ号:[1-9][0-9]{4,}中国邮政编码:[1-9]\d{5}(?!\d)身份证:\d{15}|\d{18}ip地址:\d+\.\d+\.\d+\.\d+[1-9]\d*正整数-[1-9]\d*负整数-?[1-9]\d*整数[1-9]\d*|0非负整数-[1-9]\d*|0非正整数[1-9]\d*\.\d*|0\.\d*[1-9]\d*$正浮点数-([1-9]\d
系统 2019-09-27 17:50:40 2303
一、前端概述importsocketdefmain():sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)sock.bind(('localhost',8089))sock.listen(5)whileTrue:connection,address=sock.accept()buf=connection.recv(1024)connection.sendall(bytes("HTTP/1.1201OK
系统 2019-09-27 17:50:36 2303
本文实例讲述了Pythonscipy的二维图像卷积运算与图像模糊处理操作。分享给大家供大家参考,具体如下:二维图像卷积运算一代码importnumpyasnpfromscipyimportsignal,miscimportmatplotlib.pyplotaspltimage=misc.ascent()#二维图像数组,lena图像w=np.zeros((50,50))#全0二维数组,卷积核w[0][0]=1.0#修改参数,调整滤波器w[49][25]=1.
系统 2019-09-27 17:50:25 2303
logging分为4个模块:loggers,handlers,filters,andformatters.●loggers:提供应用程序调用的接口●handlers:把日志发送到指定的位置●filters:过滤日志信息●formatters:格式化输出日志LoggerLogger.setLevel()设置日志级别Logger.addHandler()和Logger.removeHandler()增加和删除日志处理器Logger.addFilter()和Lo
系统 2019-09-27 17:49:58 2303