游走的鱼

导航

2017年4月26日 #

文件内容比较difflib

摘要: #!/usr/bin/env python#-*- coding:utf-8 -*-import difflibimport sys,osos.chdir('E:\\PythonWrok')a = open('sayhi.txt','r').readlines()b = open('hello.tx 阅读全文

posted @ 2017-04-26 17:51 游走的鱼 阅读(297) 评论(0) 推荐(0) 编辑

给文件重命名

摘要: #!/usr/bin/env python#-*- encoding:utf-8 -*-import os,os.pathdef file_rename(dir_name,file_name,des_name): os.chdir(dir_name) print '当前目录是:',os.getcwd 阅读全文

posted @ 2017-04-26 17:08 游走的鱼 阅读(144) 评论(0) 推荐(0) 编辑

批量将某一目录下的.py文件改为.txt格式文件

摘要: #!/usr/env/python#-*- coding:utf-8 -*-#批量将某一目录下的.py文件改为.txt格式文件import os,os.pathfile_list = os.listdir('E:\PythonWrok') #切换到这个目录下边E:\PythonWrokos.chdi 阅读全文

posted @ 2017-04-26 17:00 游走的鱼 阅读(470) 评论(0) 推荐(0) 编辑

2017年1月20日 #

python列表复习

摘要: 列表的切片 >>> name = list()>>> name.extend(range(100))>>> name[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 2 阅读全文

posted @ 2017-01-20 16:18 游走的鱼 阅读(115) 评论(0) 推荐(0) 编辑

python文件处理复习

摘要: 1.创建文件 >>> file('test.txt','w') -->在当前路径下创建文件 test.txt是文件名 w是打开文件的方式,r是读,w是写,a是追加,如果当前路径没有这个文件,用w可以直接创建 2.往文件中写内容 >>> file('test.txt','w').write('hell 阅读全文

posted @ 2017-01-20 11:46 游走的鱼 阅读(164) 评论(0) 推荐(0) 编辑

2017年1月18日 #

python与系统做交互常用的模块和使用方法

摘要: 1.使用os模块与系统做简单命令的交互 >>>import os >>>os.popen('pwd') <open file 'pwd', mode 'r' at 0x7f6e27b6a420> >>>a = os.popen('pwd').read() >>>a '/root\n' 2.使用os. 阅读全文

posted @ 2017-01-18 11:40 游走的鱼 阅读(161) 评论(0) 推荐(0) 编辑

python数据类型及字符编码

摘要: 一、python数据类型,按特征划分 1.数字类型 整型:布尔型(True,False)、长整型(L),会自动帮你转换成长整型、标准整型 2.序列类型 字符串(str)、元组(tuple)、列表(list) 3.映像类型 字典(dict) 4.集合类型 可变集合(set)、不可变集合 5.非整型 二 阅读全文

posted @ 2017-01-18 10:56 游走的鱼 阅读(120) 评论(0) 推荐(0) 编辑

2017年1月16日 #

安装redis,以及python如何引用redis

摘要: 下载 cd /usr/local/src/ wget http://download.redis.io/releases/redis-2.8.17.tar.gz 解压 tar -zxvf redis-2.8.17.tar.gz 安装编译组件 yum install build-essential 切 阅读全文

posted @ 2017-01-16 11:56 游走的鱼 阅读(357) 评论(0) 推荐(0) 编辑

python报错Could not open PYTHONSTARTUP

摘要: root@liqian-python:/pythonShare/monitor/m_server/core# pythonPython 2.7.10 (default, Oct 14 2015, 16:09:02) [GCC 5.2.1 20151010] on linux2Type "help", 阅读全文

posted @ 2017-01-16 10:45 游走的鱼 阅读(2255) 评论(0) 推荐(0) 编辑

2017年1月15日 #

pythonRedis 订阅功能实现

摘要: 两天机器做,host要写订阅主机的ip,客户端发消息,服务端订阅消息 cat redis_connector.py #!/usr/bin/env python__author__ = 'Q.Li'import redisr = redis.Redis(host='localhost',port=63 阅读全文

posted @ 2017-01-15 20:16 游走的鱼 阅读(209) 评论(0) 推荐(0) 编辑