- # 字符串是不可变类型 s = "pig" """ id(s) Out[18]: 4355286776 """ s = "cat" """ id(s) Out[20]: 4324273488 """ # 字符串赋值 a = "apple" b = "apple" a == b # Out[13]: True a is b # Out[12]: True id(a)... # 字符串是不可变类型 s = "pig" """ id(s) Out[18]: 4355286776 """ s = "cat" """ id(s) Out[20]: 4324273488 """ # 字符串赋值 a = "apple" b = "apple" a == b # Out[13]: True a is b # Out[12]: True id(a)...
- flake8 是 pep8(检查代码风格) 文档: doc: https://flake8.pycqa.org/pypi: https://pypi.org/project/flake8/github: http://github.com/pycqa/flake8/ 安装 pip install flake8 1 使用 # 检查文件 $ flake8 dem... flake8 是 pep8(检查代码风格) 文档: doc: https://flake8.pycqa.org/pypi: https://pypi.org/project/flake8/github: http://github.com/pycqa/flake8/ 安装 pip install flake8 1 使用 # 检查文件 $ flake8 dem...
- github: https://github.com/python-trio/trio 文档: https://trio.readthedocs.io/en/latest/tutorial.html An async/await-native I/O library for humans and snake people 安装 pip install trio 1... github: https://github.com/python-trio/trio 文档: https://trio.readthedocs.io/en/latest/tutorial.html An async/await-native I/O library for humans and snake people 安装 pip install trio 1...
- 访问类属性的顺序: getattribute -> 如果没有找到属性,则引发异常AttributeError -> AttributeError 异常会触发 getattr,如果没有实现getattr 则抛出异常 123 代码示例 # -*- coding: utf-8 -*- class Dog(object): def __getattrib... 访问类属性的顺序: getattribute -> 如果没有找到属性,则引发异常AttributeError -> AttributeError 异常会触发 getattr,如果没有实现getattr 则抛出异常 123 代码示例 # -*- coding: utf-8 -*- class Dog(object): def __getattrib...
- 一个ThreadLocal变量虽然是全局变量,但每个线程都只能读写自己线程的独立副本,互不干扰。ThreadLocal解决了参数在一个线程中各个函数之间互相传递的问题。 代码示例 # -*- coding: utf-8 -*- # @File : thread_local_demo.py # @Date : 2018-06-11 # @Author : Peng... 一个ThreadLocal变量虽然是全局变量,但每个线程都只能读写自己线程的独立副本,互不干扰。ThreadLocal解决了参数在一个线程中各个函数之间互相传递的问题。 代码示例 # -*- coding: utf-8 -*- # @File : thread_local_demo.py # @Date : 2018-06-11 # @Author : Peng...
- 相关: Python编程:json模块和pickle模块 # -*- coding: utf-8 -*- # @File : json_demo.py # @Date : 2018-06-04 # @Author : Peng Shiyu # 定制序列化或反序列化的规则 import json class Student(object): def __init... 相关: Python编程:json模块和pickle模块 # -*- coding: utf-8 -*- # @File : json_demo.py # @Date : 2018-06-04 # @Author : Peng Shiyu # 定制序列化或反序列化的规则 import json class Student(object): def __init...
- 表单扩展 Flask-WTF 文档: https://flask-wtf.readthedocs.io/en/stable/ 安装 pip install Flask-WTF 1 可以进行csrf验证 代码示例 1、定义模型类 视图使用 from flask import ( Flask, render_template, session, url_fo... 表单扩展 Flask-WTF 文档: https://flask-wtf.readthedocs.io/en/stable/ 安装 pip install Flask-WTF 1 可以进行csrf验证 代码示例 1、定义模型类 视图使用 from flask import ( Flask, render_template, session, url_fo...
- 推荐一个Chrome浏览器的xpath解析工具: xPath helper 轻松获取HTML元素的xPath 打开/关闭控制台:Ctrl-Shift键-X 参考:介绍一款chrome爬虫网页解析工具-XPath Helper scrapy基本介绍 # 创建工程 scrapy startproject myspider # 创建爬虫 scrapy ge... 推荐一个Chrome浏览器的xpath解析工具: xPath helper 轻松获取HTML元素的xPath 打开/关闭控制台:Ctrl-Shift键-X 参考:介绍一款chrome爬虫网页解析工具-XPath Helper scrapy基本介绍 # 创建工程 scrapy startproject myspider # 创建爬虫 scrapy ge...
- PyPI: https://pypi.org/project/jsmin/ Github: https://github.com/tikitu/jsmin 安装 pip install jsmin 1 使用示例 myfile.js function foo() { console.log('hi') } 123 1、命令行中使用 $ python -m j... PyPI: https://pypi.org/project/jsmin/ Github: https://github.com/tikitu/jsmin 安装 pip install jsmin 1 使用示例 myfile.js function foo() { console.log('hi') } 123 1、命令行中使用 $ python -m j...
- MySQL文档:https://dev.mysql.com/doc/connector-python/en/ PYPI: https://pypi.org/project/mysql-connector-python/ mysql-connector-python 是MySQL官方的Python语言MySQL连接模块 安装 $ pip install mysql-... MySQL文档:https://dev.mysql.com/doc/connector-python/en/ PYPI: https://pypi.org/project/mysql-connector-python/ mysql-connector-python 是MySQL官方的Python语言MySQL连接模块 安装 $ pip install mysql-...
- flask的uwsig.ini配置文件如下: [uwsgi] socket = 127.0.0.1:3031 wsgi-file = flask_web.py callable = app processes = 4 threads = 2 stats = 127.0.0.1:9191 12345678 启动 $ uwsgi uwsig.ini1 然后报错: ... flask的uwsig.ini配置文件如下: [uwsgi] socket = 127.0.0.1:3031 wsgi-file = flask_web.py callable = app processes = 4 threads = 2 stats = 127.0.0.1:9191 12345678 启动 $ uwsgi uwsig.ini1 然后报错: ...
- 发现一个比较好玩的模块,测试下: import calendar # 获取日历 cal = calendar.month(2018, 5) print(cal) """ May 2018 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2... 发现一个比较好玩的模块,测试下: import calendar # 获取日历 cal = calendar.month(2018, 5) print(cal) """ May 2018 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2...
- 安装pyinstaller 方式一: pip install pywin32 # 不安装可能会报错 pip install PyInstaller12 方式二: 下载zip文件安装 官网:http://www.pyinstaller.org/ 或者:https://pypi.python.org/pypi/PyInstaller/3.3.1 方式三: ... 安装pyinstaller 方式一: pip install pywin32 # 不安装可能会报错 pip install PyInstaller12 方式二: 下载zip文件安装 官网:http://www.pyinstaller.org/ 或者:https://pypi.python.org/pypi/PyInstaller/3.3.1 方式三: ...
- # -*- coding: utf-8 -*- # 从网络地址中解析出系统文件路径 from urlparse import urlparse #py2版本, py3不一样 from os.path import basename, dirname, join url = "https://matplotlib.org/_downloads/font_file.p... # -*- coding: utf-8 -*- # 从网络地址中解析出系统文件路径 from urlparse import urlparse #py2版本, py3不一样 from os.path import basename, dirname, join url = "https://matplotlib.org/_downloads/font_file.p...
- 普通文件读写 # 文件写入 info = { "name": "Tom", "age": 23 } f = open("info.txt", "w") f.write(str(info)) # {'name': 'Tom', 'age': 23} f.close() # 文件读取 f = open("info.txt", "r") data = eval(f.r... 普通文件读写 # 文件写入 info = { "name": "Tom", "age": 23 } f = open("info.txt", "w") f.write(str(info)) # {'name': 'Tom', 'age': 23} f.close() # 文件读取 f = open("info.txt", "r") data = eval(f.r...
上滑加载中
推荐直播
-
华为云码道Agent集成与鸿蒙实战2026/08/11 周二 19:00-21:00
王一男-华为云码道产品规划专家;李炎-华为云码道产品专家;彭江敏-华为云鸿蒙端云一体化开发专家
本次直播带你解读华为云码道7月份产品新特性、新功能。更有专家演示码道Agent Space × 钉钉机器集成实战,从0到1打通消息通道;码道鸿蒙端云一体化实战,快速搭建员工签到系统。
回顾中 -
华为云开发者AI素养直播课·第五期2026/09/04 周五 16:00-18:00
林华鼎-华为云AI开发者运营负责人;蒋春阳-华为云AI开发者案例开发专家
本期直播内容: AI工具体验营 · 第5-8课连讲。Agent-Team 多智能体协作完成毕业设计实践
回顾中 -
华为云开发者AI素养ClassRoom·第六期2026/09/08 周二 19:00-20:00
樊渊-2026华为软件挑战赛冠军
高手来了:看软挑高手解析二维排样问题—从工业难题到算法突破
回顾中
热门标签