- chrome浏览器请求头中有许多参数,分别代表的意思如下 参数示例含义AcceptAccept: */*客户端能够接收的内容类型Accept-EncodingAccept-Encoding: gzip, deflate客户端支持的压缩编码类型Accept-LanguageAccept-Language: zh-CN,zh;q=0.9,en;q=0.8浏览器可接受的语言... chrome浏览器请求头中有许多参数,分别代表的意思如下 参数示例含义AcceptAccept: */*客户端能够接收的内容类型Accept-EncodingAccept-Encoding: gzip, deflate客户端支持的压缩编码类型Accept-LanguageAccept-Language: zh-CN,zh;q=0.9,en;q=0.8浏览器可接受的语言...
- orm英文全称object relational mapping,对象映射关系 http://www.sqlalchemy.org/ 常用操作 """ MySQL-Python mysql+mysqldb://<user>:<password>@<host>[:<port>]/<dbname> pymy... orm英文全称object relational mapping,对象映射关系 http://www.sqlalchemy.org/ 常用操作 """ MySQL-Python mysql+mysqldb://<user>:<password>@<host>[:<port>]/<dbname> pymy...
- fnmatch提供了一种类似 Unix shell-style 风格的文件名匹配方式 匹配模式 * 匹配任何字符 ? 匹配一个字符 [seq] 匹配在集合seq 中的任意字符 [!seq] 匹配不在集合seq 中的任意字符 1234 代码示例 import fnmatch filenames = [ "China.txt", "Japan.txt", "Am... fnmatch提供了一种类似 Unix shell-style 风格的文件名匹配方式 匹配模式 * 匹配任何字符 ? 匹配一个字符 [seq] 匹配在集合seq 中的任意字符 [!seq] 匹配不在集合seq 中的任意字符 1234 代码示例 import fnmatch filenames = [ "China.txt", "Japan.txt", "Am...
- # my_module.py # 被用于调用测试 def hello(): print("hello")123456 解释器内部使用的方法 my_module1 = __import__("my_module") my_module1.hello() # hello1234 官方建议使用方式 import importlib module2 = im... # my_module.py # 被用于调用测试 def hello(): print("hello")123456 解释器内部使用的方法 my_module1 = __import__("my_module") my_module1.hello() # hello1234 官方建议使用方式 import importlib module2 = im...
- 依赖库: pip install scrapy-splash1 配置settings.py # splash服务器地址 SPLASH_URL = 'http://localhost:8050' # 支持cache_args(可选) SPIDER_MIDDLEWARES = { 'scrapy_splash.SplashDeduplicateArgsMiddlew... 依赖库: pip install scrapy-splash1 配置settings.py # splash服务器地址 SPLASH_URL = 'http://localhost:8050' # 支持cache_args(可选) SPIDER_MIDDLEWARES = { 'scrapy_splash.SplashDeduplicateArgsMiddlew...
- csv文件 读取保存操作 官方文档:https://docs.python.org/3/library/csv.html 写入 # -*- encoding: utf-8 -*- import csv from io import StringIO from urllib import urlopen # 按行元组参数写入 def writerCsv1(): ... csv文件 读取保存操作 官方文档:https://docs.python.org/3/library/csv.html 写入 # -*- encoding: utf-8 -*- import csv from io import StringIO from urllib import urlopen # 按行元组参数写入 def writerCsv1(): ...
- fuzzywuzzy使用编辑距离(Levenshtein Distance)来计算序列之间的差异 github: https://github.com/seatgeek/fuzzywuzzy 安装 pip install fuzzywuzzy 1 代码示例 from fuzzywuzzy import fuzz text1 = "北京绿色公交占比年底将达93... fuzzywuzzy使用编辑距离(Levenshtein Distance)来计算序列之间的差异 github: https://github.com/seatgeek/fuzzywuzzy 安装 pip install fuzzywuzzy 1 代码示例 from fuzzywuzzy import fuzz text1 = "北京绿色公交占比年底将达93...
- 列表生成器 # 列表生成式 lst = [] for i in range(10): lst.append(i * 2) print(lst) # [0, 2, 4, 6, 8, 10, 12, 14, 16, 18] # 相当于: lst = [i * 2 for i in range(10)] print(lst) # [0, 2, 4, 6, 8, 10, 1... 列表生成器 # 列表生成式 lst = [] for i in range(10): lst.append(i * 2) print(lst) # [0, 2, 4, 6, 8, 10, 12, 14, 16, 18] # 相当于: lst = [i * 2 for i in range(10)] print(lst) # [0, 2, 4, 6, 8, 10, 1...
- 文件准备 $ mkdir tmp $ cd tmp $ touch file1.txt $ touch file2.txt $ touch file3.log $ ls file1.txt file2.txt file3.log 1234567 测试 import glob # 使用零个或多个字符通配符 * glob.glob("tmp/*.txt") O... 文件准备 $ mkdir tmp $ cd tmp $ touch file1.txt $ touch file2.txt $ touch file3.log $ ls file1.txt file2.txt file3.log 1234567 测试 import glob # 使用零个或多个字符通配符 * glob.glob("tmp/*.txt") O...
- 参考了很多,总结下 Python脚本执行的方式 当模块导入直接运行(__name__ == "main") $ python 运行当前目录下py文件$ python -m 将已安装库中的模块当脚本运行 主要区别在于: 查找文件的路径不一样一个运行的是脚本,一个是模块当脚本运行 参考: PYTHON 和PYTHON-M 的区别 参考了很多,总结下 Python脚本执行的方式 当模块导入直接运行(__name__ == "main") $ python 运行当前目录下py文件$ python -m 将已安装库中的模块当脚本运行 主要区别在于: 查找文件的路径不一样一个运行的是脚本,一个是模块当脚本运行 参考: PYTHON 和PYTHON-M 的区别
- 测试过程比较啰嗦,可以直接看文章底部的结论 测试环境 python 2.7.5 读写的文本 # -*- coding: utf-8 -*- poetry = """ 相思 唐代:王维 红豆生南国,春来发几枝。 愿君多采撷,此物最相思。 """ 12345678 1、直接读写中文(正常) # -*- coding: utf-8 -*- # 写入(正常) f ... 测试过程比较啰嗦,可以直接看文章底部的结论 测试环境 python 2.7.5 读写的文本 # -*- coding: utf-8 -*- poetry = """ 相思 唐代:王维 红豆生南国,春来发几枝。 愿君多采撷,此物最相思。 """ 12345678 1、直接读写中文(正常) # -*- coding: utf-8 -*- # 写入(正常) f ...
- vars 是内建函数,返回一个字典对象 不带参数,等价于 locals(). 带参数,等价于 object.__dict__. 12 class A(object): def __init__(self): self.a = 1 self.b = 2 def keys(self): for key in vars(self).keys(): yield key d... vars 是内建函数,返回一个字典对象 不带参数,等价于 locals(). 带参数,等价于 object.__dict__. 12 class A(object): def __init__(self): self.a = 1 self.b = 2 def keys(self): for key in vars(self).keys(): yield key d...
- 先看两段代码 Python 2.7.5 # -*- coding: utf-8 -*- # 旧式类 class Foo(): pass foo = Foo() print(foo.__class__) print(type(foo)) # __main__.Foo # <type 'instance'> # obj.__class__就表示该类,但... 先看两段代码 Python 2.7.5 # -*- coding: utf-8 -*- # 旧式类 class Foo(): pass foo = Foo() print(foo.__class__) print(type(foo)) # __main__.Foo # <type 'instance'> # obj.__class__就表示该类,但...
- flask-cors模块解决Flask跨域请求Cross-Origin问题 文档:https://flask-cors.readthedocs.io/en/latest/ 安装 pip install flask-cors 1 代码示例 from flask import Flask, jsonify from flask_cors import CORS ... flask-cors模块解决Flask跨域请求Cross-Origin问题 文档:https://flask-cors.readthedocs.io/en/latest/ 安装 pip install flask-cors 1 代码示例 from flask import Flask, jsonify from flask_cors import CORS ...
- 需要在Nuget安装IronPython, 如果报错,需要更新Nuget版本则下载对应版本即可:https://dist.nuget.org/index.html 添加引用:IronPython.dll,Microsoft.Scripting.dll(在IronPython的安装目录中) c#文件:... 需要在Nuget安装IronPython, 如果报错,需要更新Nuget版本则下载对应版本即可:https://dist.nuget.org/index.html 添加引用:IronPython.dll,Microsoft.Scripting.dll(在IronPython的安装目录中) c#文件:...
上滑加载中
推荐直播
-
华为云码道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华为软件挑战赛冠军
高手来了:看软挑高手解析二维排样问题—从工业难题到算法突破
回顾中
热门标签