- 博客(8)
- 收藏
- 关注
原创 Mac安装python虚拟环境
在MAC上安装Python虚拟环境安装步骤 在MAC上安装Python虚拟环境按步骤安装完后,找不到virtualenvwrapper.sh应卸载virtualenvwrapper(pip uninstall wrapperenvwrapper),再重新安装 virtualenvwrapper 安装python虚拟环境后,每次都需要重新source .bash_profile文件详解是因为新的mac系统默认终端是zsh不再是bash,默认启动的文件是.zshrc不是.bash_prof
2021-07-10 11:07:32
509
原创 Peewee 高阶用法
Peewee 高阶用法前言本文介绍的Peewee方法语法基于PostgreSQL高阶用法元组多条件查询from peewee import Tuplee.g.: 1. model.select().where(Tuple(model.id, model.name) == (1, '胖胖'))2. model.select().where(Tuple(model.id, model.name).in_([(1, '胖胖1号'), (2, '胖胖2号')])简单Case函数from
2021-06-29 19:47:15
1711
原创 Peewee fn 用法
Peewee fn 用法本文介绍的Peewee方法语法基于PostgreSQL官方文档官方文档是这样介绍fn方法的fn:可以调用任何SQL函数
2021-06-23 08:53:42
1305
原创 TypeError: Direct assignment to the reverse side of a related set is prohibited. Use parent_id.set()
DRF接口访问报错,TypeError: Direct assignment to the reverse side of a related set is prohibited. Use parent_id.set() instead.示例class Comment(models.Model): """评论""" comment = models.CharField(max_length=20, verbose_name="评论内容") parent = models.F
2021-06-04 23:15:52
3081
原创 Python字典列表去重
Python字典列表去重最近在写代码时老是遇到 字典列表 的去重,想当然的就用上了 set(),哈哈哈哈哈直接上代码list_a = [{"name": "Tom", "age": 18}, {"name": "Jerry", "age": 18}, {"name": "Tom", "age": 18}]unique_list = list(list_a)print(unique_list)结果TypeError: unhashable type: 'dict'set / dict
2021-05-17 16:31:15
5716
1
原创 说说我对[lambda x: x*i for i in range(4)]的理解
说说我对[lambda x: x*i for i in range(4)]的理解前言 这段代码早前在群里看到过,直接上图def multipliers(): return [lambda x:i*x for i in range(4)]print([m(2) for m in multipliers()])第一眼看,不就是匿名函数吗?不就是列表推导式吗?装神弄鬼,答案简单。列表推导式里循环遍历4次,遍历结束return 出来的就是4个函数引用实例,并且i分别为 [0, 1, 2,
2021-05-09 18:07:36
7397
2
原创 Pycharm原生SQL中出现“Unable to resolve table/column xxx”
Unable to resolve table/column xxx出错示例出错原因解决方法step01step02结果出错示例出错原因未给项目指定数据库和表解决方法step01File —> Settings —> Language —> SQL Resolution Scopes —> 选择项目对应的数据库映射step02完事儿结果不仅没有了烦人的红色波浪线,还能展现数据库详细信息不得不说,Pycharm真的好好用啊。给 JetBrains 家点赞赞
2020-08-25 12:23:00
3953
原创 Pycharm原生SQL中出现SQL dialect is not configured警告
Pycharm原生SQL中出现SQL dialect is not configured警告出现的问题!出现问题原因解决方法效果图)出现的问题!出现问题原因主要是我们未在 Pycharm 中配置数据解决方法在File ----> Setting —> Languages & Frameworks —> SQL Dialects —> 选择应用到项目还是全局设置 —> 选择对应的数据库,如PostgreSQL —> Apply —> Ok效
2020-08-25 11:57:42
649
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人