摘要:
import time SLEEP = 50 def tick(): start = time.perf_counter() # hi-resolution timer (in seconds) # do something ... elapsed = int(1000 * (time.perf_c
阅读全文
posted @ 2024-08-03 13:35
ZhangZhihuiAAA
阅读(17)
推荐(0)
摘要:
A typical event-driven program is not doing anything most of the time, and its functionality is only triggered by external signals, such as user input
阅读全文
posted @ 2024-08-02 16:07
ZhangZhihuiAAA
阅读(22)
推荐(0)
摘要:
with statement Here is the syntax of the with statement: with expression as var: statements The expression should be a context manager object, or it s
阅读全文
posted @ 2024-07-31 21:50
ZhangZhihuiAAA
阅读(27)
推荐(0)
摘要:
Figure 20.4: Built-in exceptions The class BaseException is the base class of all the built-in exception classes. From BaseException, four classes nam
阅读全文
posted @ 2024-07-31 21:03
ZhangZhihuiAAA
阅读(33)
推荐(0)
摘要:
There are two approaches that can be followed when we want to deal with exceptions that occur due to unusual events: LBYL - Look Before You Leap EAFP
阅读全文
posted @ 2024-07-31 20:48
ZhangZhihuiAAA
阅读(18)
推荐(0)
摘要:
>>> list(map(lambda x, y: x * y, [1,2,3,4], [5,6,7,8])) [5, 12, 21, 32] Here we have called the map function and sent a lambda expression as first arg
阅读全文
posted @ 2024-07-31 20:13
ZhangZhihuiAAA
阅读(15)
推荐(0)
摘要:
Functional programming is a programming paradigm in which most of the work in a program is done using pure functions. A pure function is a function wi
阅读全文
posted @ 2024-07-31 17:23
ZhangZhihuiAAA
阅读(21)
推荐(0)
摘要:
We can place lambda function inside list and dictionary literals. This way we can use lambda expressions to create jump tables. >>> L = [lambda s: s.s
阅读全文
posted @ 2024-07-31 17:11
ZhangZhihuiAAA
阅读(21)
推荐(0)
摘要:
A closure is a nested function that can access free variables from an enclosing function even after it has finished its execution. We know that, like
阅读全文
posted @ 2024-07-31 17:08
ZhangZhihuiAAA
阅读(17)
推荐(0)
摘要:
We have used functions to decorate functions and to decorate classes. Now, we will see how to define a class as a decorator. At the start of this chap
阅读全文
posted @ 2024-07-31 16:24
ZhangZhihuiAAA
阅读(19)
推荐(0)