搜索到与相关的文章
Python

python里运用私有属性和方法总结

如何在PYTHON里运用私有属性和方法classFile:def__init__(self,name):self.name=nameself.code="ABCDEF"file_A=File("file_A")#假设我们有一个类,叫做文件类,设置一个对象file_A。file_A.code#如果直接调用属性,是可以看到属性里面有什么,但是如果这是个机密的密码不能公布,是不能这么处理的。classFile:def__init__(self,name):sel

系统 2019-09-27 17:57:30 2058

Python

Centos 6.4 安装Python 2.7 python-pip的详细步骤

1.准备工作下载源码包wgethttp://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2查看是否安装make工具~#rpm-qa|grepmakeautomake-1.11.1-4.el6.noarchmake-3.81-20.el6.x86_64如果没有安装make工具yum-yinstallgccautomakeautoconflibtoolmake查看是否安装zlib库~#rpm-qa|grepzl

系统 2019-09-27 17:56:34 2058

Python

Python3多线程版TCP端口扫描器

本文实例讲述了python数据结构之Array用法,分享给大家供大家参考。具体方法如下:importctypesclassArray:def__init__(self,size):assertsize>0,"Arraysizemustbe>0"self._size=sizepyArrayType=ctypes.py_object*sizeself._elements=pyArrayType()self.clear(None)defclear(self,va

系统 2019-09-27 17:55:37 2058

Python

跟老齐学Python之Import 模块

认识模块对于模块,在前面的一些举例中,已经涉及到了,比如曾经有过:importrandom(获取随机数模块)。为了能够对模块有一个清晰的了解,首先要看看什么模块,这里选取官方文档中对它的定义:复制代码代码如下:AmoduleisafilecontainingPythondefinitionsandstatements.Thefilenameisthemodulenamewiththesuffix.pyappended.Withinamodule,themo

系统 2019-09-27 17:55:19 2058

Python

python程序运行进程、使用时间、剩余时间显示功能的实现代码

有很多程序运行时间比较长,如果不将运行过程输出将很难判断程序运行的时间。下边这段程序将按照上图所示的格式输出程序运行进程、已用时间、剩余时间。deftime_change(time_init):#定义将秒转换为时分秒格式的函数time_list=[]iftime_init/3600>1:time_h=int(time_init/3600)time_m=int((time_init-time_h*3600)/60)time_s=int(time_init-t

系统 2019-09-27 17:54:42 2058

Python

python 编码处理

一、python有两种字符串类型:str和unicode1、str:常用的字符集如:gb2312、gb18030/gbk、utf-8、ascii,这些都是字符的二进制(字节)编码形式2、unicode:Python认为16位的unicode才是字符的唯一内码3、encode:从unicode转换成二进制编码,即从unicode转换成str4、decode:从二进制编码转换成unicode5、在进行同时包含str与unicode的运算时,Python一律都把

系统 2019-09-27 17:53:48 2058

Python

python批量解压zip文件的方法

这是一个用python写解压大量zip脚本的说明,本人新手一个,希望能对各位有所启发。首先要注意的,在运行自己的脚本之前一定先备份或者复制出一些样本进行测试,不然出错会很麻烦;之后我用到的是解压zip文件的扩展包zipfile,可以直接pip安装或者在IDE里安装,需要特别注意的是这个包的文件名解码方式需要我们去修改,先去查看源文件,直接搜索“cp437”(一个编码方式),找到后全部替换为“gbk”,即可解决中文显示问题。代码:importosimport

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

Python

python pandas生成时间列表

python生成一个日期列表首先导入pandasimportpandasaspddefget_date_list(begin_date,end_date):date_list=[x.strftime('%Y-%m-%d')forxinlist(pd.date_range(start=begin_date,end=end_date))]returndate_list###可以测试print(get_date_list('2018-06-01','2018-0

系统 2019-09-27 17:53:02 2058

Python

python elasticsearch从创建索引到写入数据的全过程

pythonelasticsearch从创建索引到写入数据创建索引fromelasticsearchimportElasticsearches=Elasticsearch('192.168.1.1:9200')mappings={"mappings":{"type_doc_test":{#type_doc_test为doc_type"properties":{"id":{"type":"long","index":"false"},"serial":{"t

系统 2019-09-27 17:51:01 2058