![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 76
willchen_on_the_load
这个作者很懒,什么都没留下…
展开
-
python一些好例子来快速获得技能
Unpacking Elementsfirst, *others = (1,2,3,4)first, *middle, last = (1,2,3,4)name, email, *phone_numbers = ('Jack', 'jack@gmail.com', '1234567', '122333')Keeping the last N itemscollections.deque(maxlen=5)Finding the largest or smallest N items.原创 2021-03-28 21:53:57 · 99 阅读 · 0 评论 -
python中的descriptor
what is a descriptor?Three behaviors for an attribute of an object:readsetdeleteDesctiptor is a hook when accessing an attributeDemoclass Book(object): def __init__(self): self._page = 0 @property def page(self): return原创 2021-03-07 22:46:23 · 113 阅读 · 0 评论 -
python的闭包和装饰器
closurehttps://www.programiz.com/python-programming/closuredef get_config_table(): cfg = {'a':1, 'b':2} return cfgdef get_config_index(): config_table = get_config_table() def wrapper(cfg_name): return config_table.get(cfg_name,原创 2021-03-07 22:44:40 · 124 阅读 · 1 评论 -
python的profiling和如何运行更快初探
ProfileSolutionUse time tool[willchen@dn121201 cProfile]$ /usr/bin/time -v python test.py Command being timed: "python test.py" User time (seconds): 1.17 System time (seconds): 0.14 Percent of CPU this job got: 56% Elapsed (wall clock) time (h:原创 2021-03-07 22:41:57 · 134 阅读 · 0 评论 -
python中的meta初探
Table of Contents1 About Meta1.1 type & object & class & instance1.1.0.1 instance's class1.1.0.2 class's class and parents1.1.0.3 type's parent1.2 __call__'s role in class and t原创 2021-03-07 22:39:22 · 1184 阅读 · 1 评论 -
python中的反射和自省
Introspectionexamine something, typically an object, at runtime.dir()dir(object)['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__',原创 2021-03-07 22:36:42 · 107 阅读 · 0 评论 -
python解释器初探
Usagesrun python filepython test.pyrun a module-m: modulepython -m pdb test.pypython -m pydoc -p 9000input from stdin(base) PS C:\> pythonPython 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win原创 2021-03-07 22:34:37 · 218 阅读 · 0 评论 -
python中的help
built-in help()import tensorflow as tfhelp(tf)Help on package tensorflow:NAME tensorflow - TensorFlow root packagePACKAGE CONTENTSDATA __compiler_version__ = 'MSVC 191627035' __cxx11_abi_flag__ = 0 __git_version__ = 'unknown'原创 2021-03-07 22:30:23 · 94 阅读 · 0 评论 -
python中的并发
Table of Contents1 Concurrency2 When is concurrency usefule2.1 Summary3 How to improve3.1 Synchronous Version3.2 Threading Version3.2.1 What it looks like3.2.2 downsid原创 2021-03-07 22:21:49 · 181 阅读 · 0 评论 -
一些python3比较有用的特性
What’s new in pythonThere are so many new things in Python3.8.2(can be several books), only go through and pick something interesting to introduce here.Summary from Python3.8.2 documentationWhat’s New In Python 3.0compared to 2.6Print Is A Function原创 2021-03-07 22:19:52 · 171 阅读 · 0 评论 -
深入理解Python的class
Table of Contents1 Definition1.1 1.MRO1.1.1 A Demo1.2 2.Determining the appropriate metaclass1.3 3.Preparing the class namespace1.4 4.Executing the class body1.5 5.Creating the c原创 2021-03-07 22:15:41 · 254 阅读 · 1 评论 -
几种python debugger简介
PDBRefer to: https://docs.python.org/3/library/pdb.htmla python moduleso can be executed by python -m pdb <source_file>Usagepython -m pdb <source_file>actually call Pdb()._runscript(source_file)insert by code:import pdbpdb.set_tra原创 2020-10-15 10:51:15 · 684 阅读 · 0 评论