Python中的并发编程

Python 0字

小东西

记录一些小东西。 2.18: 使用Let’s Encrypt获得免费的SSL证书 “连接是安全的” Step 1: 安装certbot apt install certbot Step 2: 获取证书 certbot certonly --standalone -d omnibbfb.top 胜利结算页面 Saving debug log to /var/log/letsencrypt/letsencrypt.log Requesting a certificate for omnibbfb.top Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/omnibbfb.top/fullchain.pem Key is saved at: /etc/letsencrypt/live/omnibbfb.top/privkey.pem This certificate expires on 2024-05-18. These files will be updated when the certificate renews. Certbot has set up a scheduled task to automatically renew this certificate in the background....

Others SSL LaTeX Python Ollama Obsidian 2244字

Collections

最近用到了Python中的collections模块,就索性整理了一下。 from collections import * 在Python官方术语对照表中或是使用print(collections.__doc__)有 This module implements specialized container datatypes providing alternatives to Python’s general purpose built-in containers, dict, list, set, and tuple. 即collections模块中提供了一些相比传统容器(字典、列表、集合以及元组)更高级的容器数据类型。包括~~(凑字数)~~: namedtuple: factory function for creating tuple subclasses with named fields (一个工厂函数,用来创建元组的子类,子类的字段是有名称的。) deque: list-like container with fast appends and pops on either end (类似列表的容器,但 append 和 pop 在其两端的速度都很快。) ChainMap: dict-like class for creating a single view of multiple mappings (类似字典的类,用于创建包含多个映射的单个视图。) Counter: dict subclass for counting hashable objects (用于计数可哈希(hashable)对象的字典子类) OrderedDict: dict subclass that remembers the order entries were added (字典的子类,能记住条目被添加进去的顺序。) defaultdict: dict subclass that calls a factory function to supply missing values (字典的子类,通过调用用户指定的工厂函数,为键提供默认值。) UserDict: wrapper around dictionary objects for easier dict subclassing (封装了字典对象,简化了字典子类化) UserList: wrapper around list objects for easier list subclassing (封装了列表对象,简化了列表子类化) UserString: wrapper around string objects for easier string subclassing (封装了字符串对象,简化了字符串子类化) 工厂方法 上文提到,稍作整理,遇事不决,问GPT。...

Python 3630字

Attributes and Methods

本文作为“一切皆对象”的下篇,主要介绍对象的属性(attribute)和方法(method)。 什么是属性和方法? 在Python官方术语对照表中是这样定义的: Attribute: A value associated with an object which is usually referenced by name using dotted expressions. It is possible to give an object an attribute whose name is not an identifier as defined by Identifiers and keywords, for example using setattr(), if the object allows it. Such an attribute will not be accessible using a dotted expression, and would instead need to be retrieved with getattr(). Method: A function which is defined inside a class body....

Python 3311字

Everything is an object in Python

本文主要想解决的问题是:在Python中什么是“一切皆对象”? 什么是对象? 在Python官方术语对照表中是这样定义的: Object: Any data with state (attributes or value) and defined behavior (methods). 什么是属性(attribute)和方法(method): Attribute: A value associated with an object which is usually referenced by name using dotted expressions. Method: A function which is defined inside a class body. If called as an attribute of an instance of that class, the method will get the instance object as its first argument (which is usually called self). 什么是函数(function)和类(class):...

Python 2048字