随笔分类 -  python 随笔

摘要:第一步,清除已经存在的缓存文件 第二步,设置.gitignore忽略 __pycache__ 阅读全文
posted @ 2020-02-23 21:15 大步向前blue 阅读(818) 评论(0) 推荐(0)
摘要:生成方式 Python中想要自动生成 model文件可以通过 sqlacodegen这个命令来生成对应的model文件 sqlacodegen 你可以通过pip去安装: 格式: 说明: mysql+pymysql : 表示连接数据库的连接方式 username : 连接MySQL数据库的用户名 pa 阅读全文
posted @ 2019-11-01 17:58 大步向前blue 阅读(1559) 评论(0) 推荐(1)
摘要:前言: 案例一: 创建一个自定义类 数据库结构 CREATE TABLE `student` ( `id` int(2) NOT NULL AUTO_INCREMENT, `name` char(20) NOT NULL, `code` char(64) NOT NULL, `sex` char(4 阅读全文
posted @ 2019-07-25 13:59 大步向前blue 阅读(2530) 评论(0) 推荐(0)
摘要:<!--?xml version="1.0" encoding="UTF-8"?--> 前言: 我找这个设置找了好久,后来在一篇博文中才找到,现在记录下来一下,顺便带图解释一下 设置步骤: File -> Setting -> Appearance & Behavior -> System Sett 阅读全文
posted @ 2019-07-12 19:25 大步向前blue 阅读(6595) 评论(0) 推荐(1)
摘要:前言 如果你跟我一样,不愿意使用 xshell 第三方工具来远程登录自己的服务器,只想使用原生的系统 terminal来做登录,那么一下的案例会让你如愿。 安装 pexpect 模块 pip install pexpect 案例 #!/usr/local/bin/python3 import pex 阅读全文
posted @ 2019-07-11 18:44 大步向前blue 阅读(1356) 评论(0) 推荐(0)
摘要:前言: 如果你跟我一样,对python的字节码感兴趣,想了解python的代码在内存中到底是怎么去运行的,那么你可以继续往下看,如果你是python新手,我建议你移步它处,本文适合有点基础的python读者。 如果你不知道怎么生成python的字节码文件,可以查阅我的 python 代码反汇编 的博 阅读全文
posted @ 2019-07-09 16:51 大步向前blue 阅读(6275) 评论(0) 推荐(1)
摘要:dis模块 Python 反汇编是通过 dis 这个模块来查看的,一般有两种方式可以用来查看 方式一: 在命令行中使用 dis 查看 >>> def test(): ... class X: ... data = 100 ... def get(self): return self.data ... 阅读全文
posted @ 2019-07-08 17:04 大步向前blue 阅读(2110) 评论(1) 推荐(0)
摘要:map — 迭代 我们查看map函数的源码: class map(object) | map(func, *iterables) --> map object | | Make an iterator that computes the function using arguments from | 阅读全文
posted @ 2019-07-08 14:28 大步向前blue 阅读(248) 评论(0) 推荐(0)
摘要:python中使用的性能测试模块是memory_profiler , 我们使用它里面的profile这个装饰器即可测试出我们的代码的内存使用情况了。 如果没有安装 memory_profiler 则使用pip 安装一下即可,我用的是python3.7的版本安装命令: 用例测试 test.py 文件: 阅读全文
posted @ 2019-07-06 14:22 大步向前blue 阅读(814) 评论(0) 推荐(0)
摘要:目录 锁的使用姿势 锁 的作用 防止死锁产生 全局锁GIL 锁的使用姿势 姿势一: threading.Lock() : 来创建锁对象 acquire() :获取锁 release() : 释放锁 import threading #创建锁对象 lock = threading.Lock() #获取 阅读全文
posted @ 2019-06-05 19:41 大步向前blue 阅读(2744) 评论(0) 推荐(0)