- Github: https://github.com/noplay/python-mysql-replication 设置同步账号权限 GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'replicator'@'%' IDENTIFIED BY '123456'; # 刷新权限 flush... Github: https://github.com/noplay/python-mysql-replication 设置同步账号权限 GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'replicator'@'%' IDENTIFIED BY '123456'; # 刷新权限 flush...
- 类继承方法对象new和initlist和dict生成全局和局部变量交换两个变量的值默认方法包管理闭包性能 1.类继承 def class_test(): class A(object): def show(self): print("class A") def hello(self): print("hello") class B(A): ... 类继承方法对象new和initlist和dict生成全局和局部变量交换两个变量的值默认方法包管理闭包性能 1.类继承 def class_test(): class A(object): def show(self): print("class A") def hello(self): print("hello") class B(A): ...
- from collections import namedtuple dct = { "name": "Tom", "age": 24 } Person = namedtuple("Person", ["name", "age"]) # 字典转为namedtuple person = Person._make(dct) print(person) # Person... from collections import namedtuple dct = { "name": "Tom", "age": 24 } Person = namedtuple("Person", ["name", "age"]) # 字典转为namedtuple person = Person._make(dct) print(person) # Person...
- __slots__限制class的属性 __slots__定义的属性仅对当前类实例起作用,对继承的子类是不起作用的 代码示例 # -*- coding: utf-8 -*- # @File : slots_demo.py # @Date : 2018-05-29 class Dog(object): def __init__(self, name): self... __slots__限制class的属性 __slots__定义的属性仅对当前类实例起作用,对继承的子类是不起作用的 代码示例 # -*- coding: utf-8 -*- # @File : slots_demo.py # @Date : 2018-05-29 class Dog(object): def __init__(self, name): self...
- 一、代理模式 代理,通常就是一个介于寻求方和提供方之间的中介系统 设计模式中,代理充当实际对象接口的类 二、使用场景 1、以简单的方式表示一个复杂系统 2、提高现有实际对象的安全性 3、为不同服务器上的远程对象提供本地接口 4、为消耗大量内存的对象提供一个轻量级的句柄 三、代理模式的优点 1、代理模式可以通过缓存笨重的对象或频繁访问的对象来提高应用程序的性能 ... 一、代理模式 代理,通常就是一个介于寻求方和提供方之间的中介系统 设计模式中,代理充当实际对象接口的类 二、使用场景 1、以简单的方式表示一个复杂系统 2、提高现有实际对象的安全性 3、为不同服务器上的远程对象提供本地接口 4、为消耗大量内存的对象提供一个轻量级的句柄 三、代理模式的优点 1、代理模式可以通过缓存笨重的对象或频繁访问的对象来提高应用程序的性能 ...
- 函数说明os.system(command)返回状态码,执行结果输出到屏幕os.popen(command).read()返回执行结果,没有状态码--subprocess.run()Python 3.5中新增的函数。执行指定的命令,等待命令执行完成后返回一个包含执行结果的CompletedProcess类的实例subprocess.call()执行指定的命令,返回命令执... 函数说明os.system(command)返回状态码,执行结果输出到屏幕os.popen(command).read()返回执行结果,没有状态码--subprocess.run()Python 3.5中新增的函数。执行指定的命令,等待命令执行完成后返回一个包含执行结果的CompletedProcess类的实例subprocess.call()执行指定的命令,返回命令执...
- 项目地址 github: https://github.com/Delgan/loguru 文档:https://loguru.readthedocs.io/en/stable/index.html 安装 pip install loguru 1 1、输出日志 from loguru import logger logger.debug("这是一条debug日... 项目地址 github: https://github.com/Delgan/loguru 文档:https://loguru.readthedocs.io/en/stable/index.html 安装 pip install loguru 1 1、输出日志 from loguru import logger logger.debug("这是一条debug日...
- 安装scrapy 官网:https://scrapy.org/download/ 使用pip安装,如果失败下载zip安装 pip install scrapy1 遇到的错误 1、安装报错: # error: command 'cl.exe' failed: No such file or directory1 解决: 下载 twisted 并安装 h... 安装scrapy 官网:https://scrapy.org/download/ 使用pip安装,如果失败下载zip安装 pip install scrapy1 遇到的错误 1、安装报错: # error: command 'cl.exe' failed: No such file or directory1 解决: 下载 twisted 并安装 h...
- 代码如下 # -*- coding: utf-8 -*- from datetime import datetime, date from flask.json import JSONEncoder class CustomJSONEncoder(JSONEncoder): def default(self, obj): if isinstance(obj, d... 代码如下 # -*- coding: utf-8 -*- from datetime import datetime, date from flask.json import JSONEncoder class CustomJSONEncoder(JSONEncoder): def default(self, obj): if isinstance(obj, d...
- 文档:https://flask.palletsprojects.com/en/1.1.x/cli/#custom-commands Flask从0.11之后开始自带命令行工具 使用示例 配合 .flaskenv 环境变量设置使用 默认: FLASK_APP=app app.py import click from flask import Flask fr... 文档:https://flask.palletsprojects.com/en/1.1.x/cli/#custom-commands Flask从0.11之后开始自带命令行工具 使用示例 配合 .flaskenv 环境变量设置使用 默认: FLASK_APP=app app.py import click from flask import Flask fr...
- # -*- coding: utf-8 -*- import re from datetime import datetime, timedelta class TimeUtil(object): @classmethod def parse_timezone(cls, timezone): """ 解析时区表示 :param timezone: str eg: +... # -*- coding: utf-8 -*- import re from datetime import datetime, timedelta class TimeUtil(object): @classmethod def parse_timezone(cls, timezone): """ 解析时区表示 :param timezone: str eg: +...
- 安装 pip install lxml1 代码示例 from lxml import etree text = """ <html> <head> <title>这是标题</title> </head> <body> <div>这是内容</div> </bod... 安装 pip install lxml1 代码示例 from lxml import etree text = """ <html> <head> <title>这是标题</title> </head> <body> <div>这是内容</div> </bod...
- 测试的目录如下: root ├── module_root.py ├── package_a │ ├── child │ │ ├── __init__.py │ │ └── child_a.py │ ├── module.py │ └── module_a.py └── package_b └── module_b.py1234567891... 测试的目录如下: root ├── module_root.py ├── package_a │ ├── child │ │ ├── __init__.py │ │ └── child_a.py │ ├── module.py │ └── module_a.py └── package_b └── module_b.py1234567891...
- 大小写转换 print("name is Alex".capitalize()) # 转为首字母大写 ->Name is alex print("name is Alex".title()) # 转为标题形式 ->Name Is Alex print("Name".upper()) # 转大写 ->NAME print("Name".lowe... 大小写转换 print("name is Alex".capitalize()) # 转为首字母大写 ->Name is alex print("name is Alex".title()) # 转为标题形式 ->Name Is Alex print("Name".upper()) # 转大写 ->NAME print("Name".lowe...
- import itertools # “无限”迭代器 # 创建一个无限的迭代器,代码会打印出自然数序列,根本停不下来,只能按Ctrl+C退出。 def testCount(): natuals=itertools.count(1) for i in natuals: print(i) # testCount() # 传入的一个序列无限重复下去 def testC... import itertools # “无限”迭代器 # 创建一个无限的迭代器,代码会打印出自然数序列,根本停不下来,只能按Ctrl+C退出。 def testCount(): natuals=itertools.count(1) for i in natuals: print(i) # testCount() # 传入的一个序列无限重复下去 def testC...
上滑加载中
推荐直播
-
用码道,让你的AI作品三步上朋友圈2026/08/04 周二 19:00-20:00
林华鼎-华为云AI开发者运营负责人
从入门 · 到做AI应用 · 到企业级开发。不教编程,只教用AI · 零代码、有产出、能带走、可炫耀 · 每课人人动手实操
回顾中 -
华为云码道Agent集成与鸿蒙实战2026/08/11 周二 19:00-21:00
王一男-华为云码道产品规划专家;李炎-华为云码道产品专家;彭江敏-华为云鸿蒙端云一体化开发专家
本次直播带你解读华为云码道7月份产品新特性、新功能。更有专家演示码道Agent Space × 钉钉机器集成实战,从0到1打通消息通道;码道鸿蒙端云一体化实战,快速搭建员工签到系统。
正在直播
热门标签