- 博客(47)
- 收藏
- 关注
原创 Python之几个简单的练习题
Python练习题:1.实现1-100的所有的和#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/10/26 9:20# @Author : hantong# @File : revise.py#实现1-100的所有的和sum = 0 for i in xrange(1,1...
2019-07-09 11:27:04
272
原创 Python之几个简单的练习题
Python练习题:1.实现1-100的所有的和#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/10/26 9:20# @Author : hantong# @File : revise.py#实现1-100的所有的和sum = 0 for i in xrange(1,1...
2019-07-08 16:17:24
230
原创 elk安装配置
ELK安装配置 作者 版本 创作日期 备注 hanson 0.1 2019-07-04 草稿 ELK简介ELK是三个开源软件的缩写,分别表示:Elasticsearch , Logstash, Kibana ,...
2019-07-04 14:18:11
225
原创 elasticsearch安装配置
es集群搭建注意细节一、修改系统配置更改系统配置:vim /etc/sysctl.confvm.max_map_count=655360vm.overcommit_memory = 1vim /etc/security/limits.conf* soft nofile 65536* hard nofile 131072* soft nproc 4096...
2019-07-04 11:15:23
259
原创 Python之sqlalchemy_2
mysql操作复习:#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2018/5/14 13:19# @Author : hantong# @File : 20180513_mysql_fuxi.py'''创建一个test库create database test;授权一个用户grant all priv...
2018-05-14 14:22:31
1598
原创 Python之sqlalchemy
Python之sqlalchemy一、把表写成类,进行数据处理#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2018/5/11 9:48# @Author : hantong# @File : 20180510_mysql_sqlalchemy.py'''表 studentid, name, age, sex, gra...
2018-05-11 13:33:14
224
原创 Python之内置函数hashlib,StringIO,BytesIO简析
内置函数简析 一、 hashlib: 代码如下:#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2018/4/27 9:01# @Author : hantong# @File : 20180426_hashlib.py#hashlib# hashlib模块代替了Python2中的md5和sham模块,...
2018-04-27 13:28:45
358
原创 Python之装饰器
Python装饰器装饰器到底是什么?简言之,python装饰器就是用于拓展原来函数功能的一种函数,这个函数的特殊之处在于它的返回值也是一个函数,使用python装饰器的好处就是在不用更改原函数的代码前提下给函数增加新的功能。先来看一个例子:#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2018/4/18 10:50# @Author...
2018-04-18 17:23:12
181
原创 python之几个练习题
练习题一:打印99乘法表#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2018/4/10 21:35# @Author : hantong# @File : 20180410_lianxi.pyfor i in range(1,10): for j in range(1,i+1): h...
2018-04-12 14:17:37
201
原创 Python之while,for,if练习题
练习题一:输入任意一个整数 求0! + 1! +2! + 3! + 4! +………………n!#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2018/4/4 9:15# @Author : hantong# @File : 20180404.pyimport mathwhile 1: str1 = inp...
2018-04-04 13:07:41
607
原创 Python之Celery(一)
Python之Celery1.celery简介celery 是一个python开发的异步分布式的任务调度模块,目前只支持rebbimg,redis,数据库等 安装celery pip install celery pip install redis2.celery小例子实例一:#!/usr/bin/env python# -*- coding:utf8
2017-12-25 15:27:08
314
原创 Python之thread(一)
Python之thread(一)1.多线程实例化#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/12/13 10:07# @Author : hantong# @File : thread_1.py#实例化多线程import threading#第一种方法import time
2017-12-13 15:36:31
675
原创 Python之process(三)
Python之process(三)1.Manager模块#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/12/12 14:48# @Author : hantong# @File : process_4.pyimport multiprocessingdef worker(d,l):
2017-12-12 16:46:23
1552
原创 Python之Process(二)
Python之Process(二)实例:#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/12/11 17:12# @Author : hantong# @File : process_3.pyimport multiprocessing# lock = multiprocessing.
2017-12-11 17:39:46
341
原创 Pyhton之process(一)
Pyhton之process(一)1.多进程概念多线程就是允许一个进程内存在多个控制权,以便让多个函数同时处于激活状态,从而让多个函数的操作同时运行。即使是单CPU的计算机,也可以通过不停地在不同线程的指令间切换,从而造成多线程同时运行的效果。 多线程相当于一个并发(concunrrency)系统。并发系统一般同时执行多个任务。如果多个任务可以共享资源,特别是同时写入某个
2017-12-11 17:11:04
267
原创 Python之memcache(二)
Python之memcache(二)1.add、replace、set#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/12/11 13:59# @Author : hantong# @File : memcache_2.pyimport memcachemc = memcache.Cli
2017-12-11 15:23:06
279
原创 Python之memcache(一)
Python之memcache(一)一、memcache安装,启动 1. cd /usr/local 2. wget http://www.memcached.org/files/memcached-1.5.3.tar.gz 3. cd memcahed-1.5.3 4. ./configure 5. make & make test(检测,可不写) & make inst
2017-12-07 10:12:18
440
原创 Python之redis(三)
python之redis之(三)1.hash操作#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/12/5 10:23# @Author : hantong# @File : redis_hash.pyimport redispool = redis.ConnectionPool(host
2017-12-05 17:08:46
187
原创 python之计算系统空闲内存、列表字典相互转换
python之计算系统空闲内存#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/30 14:25# @Author : hantong# @File : count_free_memory.py#统计linux系统空闲内存和所有内存with open('/proc/meminfo'
2017-12-01 15:15:18
773
原创 python之for、while、if练习题
python之for、while、if练习题#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/12/1 10:11# @Author : hantong# @File : for_test.py#使用for循环遍历文件with open('for.txt') as fd: f =
2017-12-01 12:04:01
2684
原创 Python之redis(二)
python之redis操作(二)1.字符串操作#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/27 10:17# @Author : hantong# @File : redis3.pyimport redispool = redis.ConnectionPool(host="1
2017-11-27 14:55:50
183
原创 Pyhton之redis
Pyhton之redis操作1.redis安装linux系统下安装:wget http://download.redis.io/releases/redis-3.0.1.tar.gztar xzf redis-3.0.1.tar.gzcd redis-3.0.1makevim redis.conf把daemonize no改为daemonize yes,这样
2017-11-24 16:14:21
263
原创 Python之mysql删改优化
Python之mysql操作1.删除数据#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/24 9:09# @Author : hantong# @File : mysql_delete.pyimport MySQLdbdef connect_mysql(): db_conf
2017-11-24 09:17:51
562
原创 Python之Mysql创建表&查询表
Python之Mysql创建表&查询表1.创建表#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/22 16:24# @Author : hantong# @File : mysql_create.pyimport MySQLdbdef connect_mysql(): db
2017-11-22 16:54:45
4294
原创 Python之mysql-pool
Python之mysql-pool1.游标游标提供了一种对从表中检索出的数据进行操作的灵活手段,就本质而言,游标实际上是一种能从包括多条数据记录的结果集中每次提取一条记录的机制。游标总是与一条SQL 选择语句相关联因为游标由结果集(可以是零条、一条或由相关的选择语句检索出的多条记录)和结果集中指向特定记录的游标位置组成。当决定对结果集进行处理时,必须声明一个指向该结果集的游标。常用
2017-11-21 16:14:04
1485
原创 Python之MySQL
Python之MySQL-python1.windows安装MySQL-python安装之前需要安装几个组件(我的系统是win7,python2.7版本): 一、 MySQL_python-1.2.5-cp27-none-win_amd64.whl 二、 setuptools 三、 wheel 四、 Microsoft Visual C++ Compiler
2017-11-21 10:07:04
279
原创 Python之re方法
Python之re方法1.re的matche和search方法#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/15 13:41# @Author : hantong# @File : re1.py#正则对象的match匹配import rereg = re.compile(r'(\
2017-11-15 16:06:30
406
原创 Python之正则表达式
Python之正则表达式1.正则表达式的大致匹配过程是:依次拿出表达式和文本中的字符比较,如果每一个字符都能匹配,则匹配成功;一旦有匹配不成功的字符则匹配失败,具体如下图:1.1 贪婪模式与非贪婪模式正则表达式通常用于在文本中查找匹配的字符串。Python里数量词默认是贪婪的(在少数语言里也可能是默认非贪婪),总是尝试匹配尽可能多的字符;非贪婪的则相反,总是尝试匹配尽可能少的字符。例如:正则表达式...
2017-11-14 16:22:33
264
原创 Python之json类型数据转换
Python之json类型数据转换json四种方法json.loads json.dumps json.load json.dump注:带s的就是来处理字符串的,没有带s的就是用来处理文件的实例:#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/13 14:07# @Author : hantong# @File ...
2017-11-13 15:02:09
1933
原创 Python之logging,os,sys,random和string模块简析
Python之logging,os,sys,random和string模块简析1.logging模块#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/10 10:00# @Author : hantong# @File : log.pyimport logginglogging.basicConfig(lev...
2017-11-10 16:43:10
459
原创 Python之time与datetime模块
python之time与datetime模块#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/9 10:23# @Author : hantong# @File : datetime.py#time模块基本不用于取时间,去时间使用datetime#time用法import timefor i in xrang...
2017-11-09 15:56:11
220
原创 Python之异常处理
Python之异常处理本节重点:理解try,Exception,raise等异常报错代码如下:#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/8 9:39# @Author : hantong# @File : except.py#异常是一个事件,是一个python对象,表示
2017-11-08 14:42:11
406
原创 Python之类的重写和私有变量
Python之类的重写和私有变量1.类的重写#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/7 10:19# @Author : hantong# @File : class4.py#类的重写class parent: name = 'parent' sex = 'M' age = 31c...
2017-11-07 15:25:38
233
原创 Python之类的构造和继承
Python之类的构造和继承类的构造:#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/6 9:46# @Author : hantong# @File : class.py#类的一般形式:一般用class关键字创建一个类,后面跟类名称,类名称可以自定义,最后以冒号结尾# 格式:# class ...
2017-11-07 10:02:48
270
原创 Python函数之生成器
Python函数之生成器#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/3 10:02# @Author : hantong# @File : genarator.py# 生成式和生成器#列表生成器li = [x*x for x in xrange(1,101) if x%2
2017-11-03 19:40:25
367
原创 Python之函数简析(二)
Python之函数本节重点理解一下map,reduce,filter,lambda,sorted函数的用法map函数实例:#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/2 9:32# @Author : hantong# @File : func.py#map函数,返回一个
2017-11-02 14:23:20
203
原创 Python之函数简析(一)
Python之函数函数分为无参函数和有参函数#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/11/1 9:01# @Author : hantong# @File : def.py#函数分为无参函数和有参函数#无参函数形如如下:def hello(): p...
2017-11-01 17:39:33
240
原创 Python之list,string,tuple,dict练习题
Python之list,string,tuple,dict练习题#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/10/30 10:11# @Author : hantong# @File : threed_week.pyimport codecs#对列表排序list = [22,4,6,
2017-10-31 14:34:07
953
原创 Python之文件读取和写入
Python之文件管理1.文件读取:导入模块:import codecs打开文件实例:#!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/10/27 9:57# @Author : hantong# @File : file.pyimport codecsf = codecs.open('1.txt',encodin...
2017-10-27 16:47:16
1956
原创 Python之几个简单的练习题
Python练习题:1.实现1-100的所有的和 #!/usr/bin/env python# -*- coding:utf8 -*-# @Time : 2017/10/26 9:20# @Author : hantong# @File : revise.py#实现1-100的所有的和sum = 0 for i in xrange(1,101):
2017-10-26 10:47:08
1882
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人