会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
goallin
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
2023年8月16日
Python 自定义运算符
摘要: # Python 自定义运算符 #### 正向运算符 ``` + __add__(self, other) - __sub__(self, other) * __mul__(self, other) / __truediv__(self, other) // __floordiv__(self, o
阅读全文
posted @ 2023-08-16 17:37 软匠
阅读(101)
评论(0)
推荐(0)
2023年8月15日
Python 类变量
摘要: # Python 类变量 除了定义对象属性外,Python 也可以定义类变量 #### 示例 ```python class ClassVariable: __object_count = 0 def __init__(self, name: str): self.name = name Class
阅读全文
posted @ 2023-08-15 19:01 软匠
阅读(47)
评论(0)
推荐(0)
2023年8月13日
Python Poetry 依赖管理工具
摘要: # Python 依赖管理工具 poetry ## 安装 Linux, macOS, Windows (WSL) ``` curl -sSL https://install.python-poetry.org | python3 - ``` Windows (Powershell) ``` (Inv
阅读全文
posted @ 2023-08-13 16:14 软匠
阅读(707)
评论(0)
推荐(0)
2023年8月12日
Python 访问控制
摘要: # Python 访问控制 Java 中采用 public, protected, private 等修饰符来控制访问, Python 则采用命令约定来控制访问,一个下划线_开头表示保护方法,两个下划线__开头表示私有方法 Python 使用 @property 和 property setter
阅读全文
posted @ 2023-08-12 12:07 软匠
阅读(56)
评论(0)
推荐(0)
2023年8月11日
Python 复杂数据排序
摘要: # Python 复杂数据排序 通过自定义函数作为 sort 的 key 来排序复杂数据 ``` def by_urgency(task): return task['urgency'] def test_sort_complicated(): tasks = [ {'title': 'Laundr
阅读全文
posted @ 2023-08-11 16:11 软匠
阅读(20)
评论(0)
推荐(0)
2023年8月10日
python dict 和 object 相互转换
摘要: # python dict 和 object 的相互转换 dict.py 借助 __dict__, isinstance 来实现对象与字典之间的相互转换 ``` def as_dict(obj): if not hasattr(obj, "__dict__"): return obj result
阅读全文
posted @ 2023-08-10 17:35 软匠
阅读(240)
评论(0)
推荐(0)
2023年8月9日
Java 9 新特性
摘要: # Java 9 新特性 ## 模块化系统 Java 9 引入模块化系统的一个原因是为了让 Java 可以运行在内存有限的场景 模块可以导出 Public API 隐藏内部实现,模块可以依赖其它模块 ``` module tech.ruanjiang.modules.car { requires t
阅读全文
posted @ 2023-08-09 15:02 软匠
阅读(24)
评论(0)
推荐(0)
2023年8月8日
Java 11 新特性
摘要: # Java 11 新特性 Java 11 是 Java 8 之后的第一个长期支持版本 (long term suppoert LTS),Oracle 将在 2019年1月停止支持 Java 8. # Oracle VS Open JDK Java 10 是最后一个免许可商用版本,如果不需要 Ora
阅读全文
posted @ 2023-08-08 15:02 软匠
阅读(73)
评论(0)
推荐(0)
2023年8月7日
Go / Golang JSON 一些心得
摘要: ## 自定义序列化和反序列化 可以实现 json.Marshaler 和 json.Unmarshaler 自定义json的序列化和反序列化 ``` type Tags []string func (t Tags) MarshalJSON() ([]byte, error) { return []b
阅读全文
posted @ 2023-08-07 18:32 软匠
阅读(99)
评论(0)
推荐(0)
上一页
1
2
公告