摘要:
1. Object Representations Every object-oriented language has at least one standard way of getting a string representation from any object. Python has 阅读全文
摘要:
1. Varaibles Are Labels, Not Boxes. Python varaibles are like reference variables in Java, so it's better to think of them as labels attached to objec 阅读全文
摘要:
Function decorators let us "mark" functions in the source code to enhance their behavior in some way. This is powful stuff, but mastering it requires 阅读全文
摘要:
Although design patterns are language-independent, that does not mean every pattern applies to every language. If we assumed procedural languages, we 阅读全文
摘要:
The "First-Class object" in Python: Created at runtime Assigned to a variable or element in a data structure Pass as an augument to a function Return 阅读全文
摘要:
1. Handling missing keys with setdefault import sys import re WORD_RE = re.compile('\w+') index = {} print(sys.argv) # Example 3-2 with open(sys.argv[ 阅读全文
摘要:
1. Managing Ordered Sequences with bisect The bisect module offers two main functions bisect and insort that use the binary serach algorithm to quickl 阅读全文
摘要:
1. Listcomps (List comprehensions) do everything the map and filter functions do. (map 函数和 filter函数能做的,列表生成式都可以做) 列表生成式和 map, filter 函数运行时间的比较示例: impo 阅读全文
摘要:
列表推导式总共有两种形式: ① [x for x in data if condition] # 此处if主要起条件判断作用,data数据中只有满足if条件的才会被留下,最后统一生成为一个数据列表 ② [exp1 if condition else exp2 for x in data] # 此处i 阅读全文
摘要:
Markdown 是一种轻量级标记语言,它允许人们使用易读、易写的纯文本格式编写文档。Markdown 语言需要经过编辑器的渲染才能呈现出各种优美的格式。 Markdown 的使用场景: 当你对文章的排版没什么特殊需求,且不想花太多时间在排版上时,就可以使用 Markdown。因为编辑器或平台会通过 阅读全文