随笔分类 - python 基础知识
主要记载学习Python知识点
摘要:python项目打包成可执行文件 为了方便程序的运行,Python提供了第三方库pyinstaller可以很方便的将项目打包成可执行的exe程序,安装方法:pip install pyinstaller 1、使用方法: -F 选项可以打出一个exe文件,默认是 -D,意思是打成一个文件夹。 -w 选
阅读全文
摘要:# -*- coding: utf-8 -*- import uuid def get_mac_address(): address = hex(uuid.getnode())[2:] mac = '-'.join(address[i:i + 2] for i in range(0, len(add
阅读全文
摘要:###主题:python 源码编译 我们通常编写了python 脚本,但是这些python 属于接释性执行的源码并不利于系统快速的执行,所以我们需要将python 源码编译成系统文件。 下面我们就展开研究,实现源码编译过程,完成编译任务。 ###准备工作: ####1、linux python 环境
阅读全文
摘要:###今天突发奇想的用sed 搞日志,下面是需求 查询出昨天6点到今天9点的日志,那就用下面这个命令去搞它。 sed -n '/Tue Dec 15 06/,/Wed Dec 16 09/p' vsftpd.log > aaaa.txt ###过滤出带“OK” 的行 grep "OK" vsftpd
阅读全文
摘要:方法一、使用os模块的system方法:os.system(cmd), 其返回值是shell指令运行后返回的状态码, int类型, 0--表示shell指令成功执行, 256--表示shell未找到, 该方法适用于shell命令不需要输出内容的场景。 方法二、使用os.popen(), 该方法以文件
阅读全文
摘要:Sample.txt 文件有若干行,每行包含时间信息和若干列(Time | col1 | col2 | col3 | col4 | … ),每行的列数不固定 2020:11:20 11:00:00|a|b|cc|asd 2020:11:20 11:01:00|m|n|x|d|c 2020:11:20
阅读全文
摘要:# coding=utf-8import timedef outer(fun): def inner(): start = time.time() fun() runtime = time.time() - start print runtime return inner@outerdef a_fu
阅读全文