- 装饰器: 定义:本质是函数,装饰其他函数,为其他函数添加附加功能 原则: 1、不能修改被装饰的函数源代码 2、不能修改被装饰的函数的调用方式 原理: 1.函数即“变量” 2.高阶函数 a.把函数名当做实参传递给函数b.返回一个函数名 3.嵌套函数 总结: 高阶函数 + 嵌套函数 =》 装饰器 import time def timer(arg): # 可以接... 装饰器: 定义:本质是函数,装饰其他函数,为其他函数添加附加功能 原则: 1、不能修改被装饰的函数源代码 2、不能修改被装饰的函数的调用方式 原理: 1.函数即“变量” 2.高阶函数 a.把函数名当做实参传递给函数b.返回一个函数名 3.嵌套函数 总结: 高阶函数 + 嵌套函数 =》 装饰器 import time def timer(arg): # 可以接...
- python实现脚本命令行的库有: 内置库sys内置库argparse第三方库click第三方库fire 内置库sys sys.argv 包含命令行参数列表,第一个参数是文件名 sys_demo.py import sys def add(a, b): return a + b if __name__ == '__main__': ret = add(s... python实现脚本命令行的库有: 内置库sys内置库argparse第三方库click第三方库fire 内置库sys sys.argv 包含命令行参数列表,第一个参数是文件名 sys_demo.py import sys def add(a, b): return a + b if __name__ == '__main__': ret = add(s...
- 文档:http://docs.peewee-orm.com/ 安装 $ pip install peewee 1 将已有数据表转为Model # 导出数据表为Model $ python -m pwiz -e mysql -H localhost -p 3306 -u root -P -o -i -t user data > user.py 12 打印执... 文档:http://docs.peewee-orm.com/ 安装 $ pip install peewee 1 将已有数据表转为Model # 导出数据表为Model $ python -m pwiz -e mysql -H localhost -p 3306 -u root -P -o -i -t user data > user.py 12 打印执...
- python 递归调用默认上限:1000次 1、比较运算符: __cmp__(self,other)比较 __eq__(self,other)相等 __lt__(self,other)小于 __gt__(self,other)大于 2、逻辑运算符: __... python 递归调用默认上限:1000次 1、比较运算符: __cmp__(self,other)比较 __eq__(self,other)相等 __lt__(self,other)小于 __gt__(self,other)大于 2、逻辑运算符: __...
- money模块对货币进行简单的包装,实现简单的货币计算 安装 pip install money 1 代码示例 from money import Money m1 = Money("2.0", "RMB") print(m1) # RMB 2.00 print(m1.amount) # 2.0 print(m1.currency) # RMB m2 =... money模块对货币进行简单的包装,实现简单的货币计算 安装 pip install money 1 代码示例 from money import Money m1 = Money("2.0", "RMB") print(m1) # RMB 2.00 print(m1.amount) # 2.0 print(m1.currency) # RMB m2 =...
- 参照我原来的文章打包上传pypi包时报错: Python编程:为世界贡献你的轮子-pipy打包 error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>1 看到网上说此方法已经不支持 需要用 twine 模块打包 ... 参照我原来的文章打包上传pypi包时报错: Python编程:为世界贡献你的轮子-pipy打包 error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>1 看到网上说此方法已经不支持 需要用 twine 模块打包 ...
- itertools库包含: 无限迭代器有限序列处理排列组合 range对象 # 添加函数说明 def print_info(obj: "iter object") -> "print_info": print(obj) print(type(obj)) print(list(obj)) # help(print_info) # print_info(... itertools库包含: 无限迭代器有限序列处理排列组合 range对象 # 添加函数说明 def print_info(obj: "iter object") -> "print_info": print(obj) print(type(obj)) print(list(obj)) # help(print_info) # print_info(...
- 模块介绍: Reads the key,value pair from .env file and adds them to environment variable. Do one thing, do it well! pypi: https://pypi.org/project/python-dotenv/ github: https://github.com/t... 模块介绍: Reads the key,value pair from .env file and adds them to environment variable. Do one thing, do it well! pypi: https://pypi.org/project/python-dotenv/ github: https://github.com/t...
- # -*- coding:utf-8 -*- class Clazz: name = "" def getName(self): pass def getAge(self): pass def get_methods(self): return (list(filter(lambda m: not m.startswith("_") and callable(g... # -*- coding:utf-8 -*- class Clazz: name = "" def getName(self): pass def getAge(self): pass def get_methods(self): return (list(filter(lambda m: not m.startswith("_") and callable(g...
- 经常使用flask的快速搭建效果,总是忘记,记录下 代码示例 # 迭代列表 {% for row in rows %} {{ row }} {% endfor %} # 迭代字典 {% for key, value in row.items() %} {{ key }} {{ value }} {% endfor %} 12345678910 经常使用flask的快速搭建效果,总是忘记,记录下 代码示例 # 迭代列表 {% for row in rows %} {{ row }} {% endfor %} # 迭代字典 {% for key, value in row.items() %} {{ key }} {{ value }} {% endfor %} 12345678910
- 图像的基本使用屏幕的帧率设置键盘的基本使用 安装 pip install pygame 1 windows测试: python ‐m pygame.examples.aliens 1 Pygame最小开发框架 # -*- coding: utf-8 -*- # @File : pygame_demo.py # @Date : 2018-05-22 ""... 图像的基本使用屏幕的帧率设置键盘的基本使用 安装 pip install pygame 1 windows测试: python ‐m pygame.examples.aliens 1 Pygame最小开发框架 # -*- coding: utf-8 -*- # @File : pygame_demo.py # @Date : 2018-05-22 ""...
- Supervisor是进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时能自动重启。 单纯的讲理论比较难懂,下面通过一个监控flask程序的实例来探究 文档:http://supervisord.org/index.html 安装 $ pip install supervisor 1 新建一个flask项目 新建serve... Supervisor是进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时能自动重启。 单纯的讲理论比较难懂,下面通过一个监控flask程序的实例来探究 文档:http://supervisord.org/index.html 安装 $ pip install supervisor 1 新建一个flask项目 新建serve...
- urlparse 类似处理操作系统路径的 os.path 模块,能够很好的处理网址路径 导入模块 python3 from urllib.parse import urlparse, urljoin1 python2 from urlparse import urlparse, urljoin1 使用测试 url = "https://cdn.itjuzi... urlparse 类似处理操作系统路径的 os.path 模块,能够很好的处理网址路径 导入模块 python3 from urllib.parse import urlparse, urljoin1 python2 from urlparse import urlparse, urljoin1 使用测试 url = "https://cdn.itjuzi...
- 1、对单个字符串编码 from urllib.parse import quote, unquote # 编码 print(quote("美国")) # %E7%BE%8E%E5%9B%BD # 解码 print(unquote("%E7%BE%8E%E5%9B%BD")) # 美国 123456789 2、对key-value字典数据编码 from urll... 1、对单个字符串编码 from urllib.parse import quote, unquote # 编码 print(quote("美国")) # %E7%BE%8E%E5%9B%BD # 解码 print(unquote("%E7%BE%8E%E5%9B%BD")) # 美国 123456789 2、对key-value字典数据编码 from urll...
- python2 $ workon py2 (py2)$ python Python 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin Type "help", "copyright", "credit... python2 $ workon py2 (py2)$ python Python 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin Type "help", "copyright", "credit...
上滑加载中
推荐直播
-
HDC深度解读系列 - Serverless与MCP融合创新,构建AI应用全新智能中枢2025/08/20 周三 16:30-18:00
张昆鹏 HCDG北京核心组代表
HDC2025期间,华为云展示了Serverless与MCP融合创新的解决方案,本期访谈直播,由华为云开发者专家(HCDE)兼华为云开发者社区组织HCDG北京核心组代表张鹏先生主持,华为云PaaS服务产品部 Serverless总监Ewen为大家深度解读华为云Serverless与MCP如何融合构建AI应用全新智能中枢
回顾中 -
关于RISC-V生态发展的思考2025/09/02 周二 17:00-18:00
中国科学院计算技术研究所副所长包云岗教授
中科院包云岗老师将在本次直播中,探讨处理器生态的关键要素及其联系,分享过去几年推动RISC-V生态建设实践过程中的经验与教训。
回顾中 -
一键搞定华为云万级资源,3步轻松管理企业成本2025/09/09 周二 15:00-16:00
阿言 华为云交易产品经理
本直播重点介绍如何一键续费万级资源,3步轻松管理成本,帮助提升日常管理效率!
回顾中
热门标签