- supervisor 进程管理工具 安装 python2 pip install supervisor 1 配置 $ mkdir config # 生成配置文件 $ echo_supervisord_conf > config/supervisord.conf 1234 修改配置文件 config/supervisord.conf 1、开启web管... supervisor 进程管理工具 安装 python2 pip install supervisor 1 配置 $ mkdir config # 生成配置文件 $ echo_supervisord_conf > config/supervisord.conf 1234 修改配置文件 config/supervisord.conf 1、开启web管...
- # / 浮点除法 1/2 # 0.5 # // 整除 向下取整 等同于 math.floor() 1//2 # 0 -1//2 # -1 # % 取模运算 1%2 # 1 # divmod(a, b)取商和余数 = (a // b, a % b) divmod(1, 2) # (0, 1) 12345678910111213 # / 浮点除法 1/2 # 0.5 # // 整除 向下取整 等同于 math.floor() 1//2 # 0 -1//2 # -1 # % 取模运算 1%2 # 1 # divmod(a, b)取商和余数 = (a // b, a % b) divmod(1, 2) # (0, 1) 12345678910111213
- 使用shortuuid可以生成短的uuid,之前用文件的MD5值作为唯一标识,如果没有具体的加密可以使用这个 内部使用基于随机数的uuid4()来生成唯一的uudi 安装 pip install shortuuid1 示例 >>> import shortuuid >>> shortuuid.uuid() 'vytxeTZ... 使用shortuuid可以生成短的uuid,之前用文件的MD5值作为唯一标识,如果没有具体的加密可以使用这个 内部使用基于随机数的uuid4()来生成唯一的uudi 安装 pip install shortuuid1 示例 >>> import shortuuid >>> shortuuid.uuid() 'vytxeTZ...
- 类:某种类型集合的描述。举例:人 属性 类本身的一些特性,如名字、身高和体重等属性 属性具体值则会根据每个人的不同而不同; 方法 类所能实现的行为,如吃饭、走路和睡觉等方法。 类的定义 class classname[(父类名)]:[成员函数及成员变量]... 类:某种类型集合的描述。举例:人 属性 类本身的一些特性,如名字、身高和体重等属性 属性具体值则会根据每个人的不同而不同; 方法 类所能实现的行为,如吃饭、走路和睡觉等方法。 类的定义 class classname[(父类名)]:[成员函数及成员变量]...
- 异常处理 d= [] try: d.append("1") except IndexError as e: print("索引越界",e) except Exception as e: #抓住所有错误,一般放在最后 print("未知错误",e) else: print("一切正常") finally: print("不管有没有错,都执行") """常见异常... 异常处理 d= [] try: d.append("1") except IndexError as e: print("索引越界",e) except Exception as e: #抓住所有错误,一般放在最后 print("未知错误",e) else: print("一切正常") finally: print("不管有没有错,都执行") """常见异常...
- js java php 等语言: ret = 1 == 1 ? "true" : "false" 1 Python为啥不走寻常路 ret = 'true' if 1==1 else 'false' 1 js java php 等语言: ret = 1 == 1 ? "true" : "false" 1 Python为啥不走寻常路 ret = 'true' if 1==1 else 'false' 1
- 浮点型加法 0.1+0.2 Out[15]: 0.30000000000000004 12 decimal定点数加法 import decimal decimal.Decimal(0.1) + decimal.Decimal(0.2) Out[17]: Decimal('0.3000000000000000166533453694') # 设置精度 decim... 浮点型加法 0.1+0.2 Out[15]: 0.30000000000000004 12 decimal定点数加法 import decimal decimal.Decimal(0.1) + decimal.Decimal(0.2) Out[17]: Decimal('0.3000000000000000166533453694') # 设置精度 decim...
- 文档:https://hashids.org/ Python实现: https://github.com/davidaurelio/hashids-python 安装 pip install hashids 1 使用示例 # -*- coding: utf-8 -*- from hashids import Hashids hashids = Hashid... 文档:https://hashids.org/ Python实现: https://github.com/davidaurelio/hashids-python 安装 pip install hashids 1 使用示例 # -*- coding: utf-8 -*- from hashids import Hashids hashids = Hashid...
- 平时使用的都是Python2,所以这个编码问题一直困扰着我,祝大家早日升级Python3 python2 和 python3的字符串类型 # 3.6.0 >>> type("你好") <class 'str'> # 2.7.5 >>> type("你好") <type 'str'> # 引入新特性之后... 平时使用的都是Python2,所以这个编码问题一直困扰着我,祝大家早日升级Python3 python2 和 python3的字符串类型 # 3.6.0 >>> type("你好") <class 'str'> # 2.7.5 >>> type("你好") <type 'str'> # 引入新特性之后...
- 文档:https://daringfireball.net/projects/markdown/ Github: https://github.com/Python-Markdown/markdown/ John Gruber’s Markdown: https://python-markdown.github.io/reference/ 安装 pip inst... 文档:https://daringfireball.net/projects/markdown/ Github: https://github.com/Python-Markdown/markdown/ John Gruber’s Markdown: https://python-markdown.github.io/reference/ 安装 pip inst...
- 推导式,其实就是将多行的循环语句放到一行写 # -*- coding: utf-8 -*- # 列表推导式 lst = [i for i in range(5)] print(lst) # [0, 1, 2, 3, 4] # 相当于 lst2 = list() for i in range(5): lst2.append(i) print(lst2) # [... 推导式,其实就是将多行的循环语句放到一行写 # -*- coding: utf-8 -*- # 列表推导式 lst = [i for i in range(5)] print(lst) # [0, 1, 2, 3, 4] # 相当于 lst2 = list() for i in range(5): lst2.append(i) print(lst2) # [...
- 源码: from tkinter import * def main(): tk = Tk() canvas =&nbs... 源码: from tkinter import * def main(): tk = Tk() canvas =&nbs...
- pypi: https://pypi.org/project/colorama/ 安装 pip install colorama 1 代码示例 from colorama import Fore print(Fore.GREEN + "green") 12345 显示效果: pycharm linux控制台 这不禁然我想起了我之前写的库:conso... pypi: https://pypi.org/project/colorama/ 安装 pip install colorama 1 代码示例 from colorama import Fore print(Fore.GREEN + "green") 12345 显示效果: pycharm linux控制台 这不禁然我想起了我之前写的库:conso...
- 非常棒的东西 介绍: xPath helper是一款Chrome浏览器的开发者插件 作用: 通过xPath语法轻松获取HTML元素 安装: 1. chrome应用商店 2. chrome插件网(http://www.cnplugins.com/) 使用: Ctrl + Shift + X 激活 再次按Ctrl-Shift键-X关闭 参考:介... 非常棒的东西 介绍: xPath helper是一款Chrome浏览器的开发者插件 作用: 通过xPath语法轻松获取HTML元素 安装: 1. chrome应用商店 2. chrome插件网(http://www.cnplugins.com/) 使用: Ctrl + Shift + X 激活 再次按Ctrl-Shift键-X关闭 参考:介...
- scrapy命令失效,直接运行爬虫,无论是什么命令,都直接运行单个爬虫 出现这个错误,很意外 原因是这样的: 一开始,我写了个脚本单独配置爬虫启动项: # begin.py from scrapy import cmdline cmdline.execute("scrapy crawl myspider")1234 这样一来会比较方便,不用每次都去命令行敲命... scrapy命令失效,直接运行爬虫,无论是什么命令,都直接运行单个爬虫 出现这个错误,很意外 原因是这样的: 一开始,我写了个脚本单独配置爬虫启动项: # begin.py from scrapy import cmdline cmdline.execute("scrapy crawl myspider")1234 这样一来会比较方便,不用每次都去命令行敲命...
上滑加载中
推荐直播
-
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步轻松管理成本,帮助提升日常管理效率!
回顾中
热门标签