04 2019 档案

 
python之re模块
摘要:re . 匹配除换行符以外的任意字符 \w 匹配字母或数字或下划线或汉字 \s 匹配任意的空白符 \d 匹配数字 \b 匹配单词的开始或结束 ^ 匹配字符串的开始 $ 匹配字符串的结束 * 重复零次或更多次 + 重复一次或更多次 ? 重复零次或一次 {n} 重复n次 {n,} 重复n次或更多次 {n,m} 重复n到m次 # import re # matc... 阅读全文
posted @ 2019-04-28 21:55 王会喜 阅读(227) 评论(0) 推荐(0) 编辑
python之shell
摘要:import subprocess # 返回命令执行结果 # result = subprocess.call('ls -l', shell=True) # result = subprocess.call(['ls', '-l'], shell=False) # print(result) # subprocess.check_call(["ls", "-l"]) # subproce... 阅读全文
posted @ 2019-04-28 21:53 王会喜 阅读(326) 评论(0) 推荐(0) 编辑
python之zip打包
摘要:import zipfile # 压缩 z = zipfile.ZipFile('z.zip', 'w') z.write('xo.xml') z.write('xxxoo.xml') z.close() # 解压 z = zipfile.ZipFile('z.zip', 'r') for item in z.namelist(): print(item) # z.extract... 阅读全文
posted @ 2019-04-28 21:51 王会喜 阅读(5500) 评论(0) 推荐(0) 编辑
python之shutil
摘要:''' shutil 用来处理 文件 文件夹 压缩包 的模块 ''' import shutil # 拷贝文件内容 shutil.copyfileobj(open('old.xml', 'r'), open('new.xml', 'w')) # 拷贝文件 shutil.copyfile('f1.log', 'f2.log') # 拷贝权限 shutil.copymode('f1.lo... 阅读全文
posted @ 2019-04-28 21:50 王会喜 阅读(249) 评论(0) 推荐(0) 编辑
python之sys模块
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- ''' 用于对Python解释器相关操作: sys.argv 命令行参数List,第一个元素是程序本身路径 sys.exit(n) 退出程序,正常退出时exit(0) sys.version 获取Python解释程序的版本信息 sys.maxint ... 阅读全文
posted @ 2019-04-28 21:47 王会喜 阅读(164) 评论(0) 推荐(0) 编辑
python之os
摘要:os 系统级别的操作 os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径 os.chdir("dirname") 改变当前脚本工作目录;相当于shell下cd os.curdir 返回当前目录: ('.') os.pardir 获取当前目录的... 阅读全文
posted @ 2019-04-28 21:47 王会喜 阅读(145) 评论(0) 推荐(0) 编辑
python之log
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- ''' ''' import logging # 设置输出文件、文件格式和日志级别 logging.basicConfig(filename='example.log', level=logging.INFO, format='%(asctime)s %(mess... 阅读全文
posted @ 2019-04-28 21:46 王会喜 阅读(698) 评论(0) 推荐(0) 编辑
python之pickle
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- ''' ''' import pickle # pickle 只能Python识别 不适用于别的语言 li = [11, 22, 33, 433, 'sd'] r = pickle.dumps(li) print(r) print "*******" result = pickle.loads(r) pri... 阅读全文
posted @ 2019-04-28 21:45 王会喜 阅读(172) 评论(0) 推荐(0) 编辑
python之json模块
摘要:运行结果:('{"k1": "v1"}', <type 'str'>)('{"k1": 123}', <type 'dict'>)({u'k1': u'v1'}, <type 'dict'>) 阅读全文
posted @ 2019-04-28 21:43 王会喜 阅读(162) 评论(0) 推荐(0) 编辑
python之UUID
摘要:运行结果:275e1dc0-6178-11e9-b35f-005056c00008f15bb8f8-2f0c-3b7c-9ee7-79b874d9837b5151bf6b-ea42-4193-8e7b-32644e9adaaf62740382-6394-5d1c-b9ef-d5a953ac1213 阅读全文
posted @ 2019-04-28 21:41 王会喜 阅读(1362) 评论(0) 推荐(0) 编辑
python获取系统时间
摘要:运行结果:2019 4 17 15 4 59 4时间:(%Y-%m-%d %H:%M:%S %f): 2019-04-17 15:04:59 815000时间:(%Y-%m-%d %H:%M:%S %p): 19-04-17 03:04:59 PM星期缩写%a: Wed 星期全拼%A: Wednes 阅读全文
posted @ 2019-04-28 21:39 王会喜 阅读(16153) 评论(0) 推荐(1) 编辑
python之线程
摘要:运行结果: (have join()) 线程开始:1555399104.58999线程结束:1555399114.58主线程打印开始:1555399114.5801234主线程打印结束:1555399116.58 运行结果:(no join()) 线程开始:1555399270.59主线程打印开始: 阅读全文
posted @ 2019-04-28 21:31 王会喜 阅读(211) 评论(0) 推荐(0) 编辑
python之xml 文件的读取方法
摘要:''' xml 文件的读取方法 ''' #!/usr/bin/env python # -*- coding: utf-8 -*- import xml.etree.ElementTree as ET from datetime import datetime tree = ET.parse("country.xml") root = tree.getroot() print "*****... 阅读全文
posted @ 2019-04-28 21:29 王会喜 阅读(2948) 评论(0) 推荐(0) 编辑
pyQT4和pyQT5的主要模块介绍
摘要:下面简单介绍一下pyQT4和pyQT5的主要模块 阅读全文
posted @ 2019-04-28 21:26 王会喜 阅读(1077) 评论(0) 推荐(0) 编辑
python之type函数
摘要:python 的type 函数 的介绍的 下面就是此函数的参数 三个参数的意义 '''type(class_name, base_class_tuple, attribute_dict)class_name type创建类的名称,就是通常定义类的类名base_class_tuple type创建类所 阅读全文
posted @ 2019-04-28 21:17 王会喜 阅读(3643) 评论(0) 推荐(0) 编辑
shell 编程初级
摘要:shell编程的简单代码 一些基础代码 直接上代码 运行结果: 阅读全文
posted @ 2019-04-28 20:46 王会喜 阅读(186) 评论(0) 推荐(0) 编辑
python __call__方法的使用
摘要:介绍一下python __call__ 方法的使用 代码如下: 运行结果: call common_methodcall __call__ 阅读全文
posted @ 2019-04-13 18:55 王会喜 阅读(3594) 评论(0) 推荐(0) 编辑
python 的__init__ 和__new__ 区别
摘要:在此介绍一下 __init__ 和 __new__ 先后调用的区别 代码如下: 运行结果: call newcall init 阅读全文
posted @ 2019-04-13 18:51 王会喜 阅读(353) 评论(0) 推荐(0) 编辑
python读写修改配置文件(ini)
摘要:python 有时候参数需要保存到配置文件中 接下来总结一下 配置文件的读写和修改的操作 代码如下: 运行结果: aaeb519d3f276b810d46642d782d8921 阅读全文
posted @ 2019-04-13 18:43 王会喜 阅读(7576) 评论(0) 推荐(0) 编辑
python日志等级输出删选
摘要:有时候我们会删选一下输出的信息 当做日志进行文件保存 但是我们程序中有可能有自己不想存到日志文件中的输出信息 我们要做一些的删选 然后进行保存 代码如下: 运行结果: 阅读全文
posted @ 2019-04-13 18:40 王会喜 阅读(638) 评论(0) 推荐(0) 编辑
C++STL二维vector指定位置排序
摘要:自己一直用vector 二维的存储变量 有时候需要进行排序 在此 为记录一下方法 废话少说直接上代码 运行结果: 阅读全文
posted @ 2019-04-03 11:31 王会喜 阅读(3316) 评论(0) 推荐(0) 编辑