Python 文章集锦

这篇文章主要用来记录跟 Python 语法相关的博客,方便笔者日后查阅。

  • 增加摘要
  • 丰富内容
  • 分门别类

with

Context Managers and the “with” Statement in Python – Dan Bader

文件处理

Working with Files in Python – Vuyisile Ndlovu

内存管理

Memory Management in Python – Alexander VanTol

生成器

Generator Expressions in Python: An Introduction – Dan Bader

全局解释所(GIL)

What Is the Python Global Interpreter Lock (GIL)? – Abhinav Ajitsaria

关于 if __name__ == '__main__' 的解释

What does if name == “main”: do? – stackoverflow

Python 中的 if name == ‘main’ 该如何理解

OrderedDict 和 Dict 的区别

摘要
过去的很多年间,Python 中的 dict 是无序的数据结构,也就是说数据插入的顺序不会被存储的,所以想要按照插入顺序遍历字典往往需要借助其他的工具(比如列表)。针对这个问题,Python 的开发者们提出了 OrderedDict,一种按照键插入顺序来保存键值对的字典(在Python 3.1 提出)。

但是,在Python 3.6 之后,dict 变成了一个有序的数据结构,换句话说 OrderedDict要解决的问题好像不存在了。
那么我们还需要使用 OrderedDict 吗?下文就探讨了这个问题。

OrderedDict vs dict in Python: The Right Tool for the Job

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值