随笔分类 -  python

函数
摘要:Question pytorch 中定义的神经网络类的 __init__() 中,经常定义 super(类名, self).__init__(), 解释下这句话。比如: class TestNN(nn.Module): # 初始化函数 def __init__(self, parm1, ...): 阅读全文
posted @ 2024-09-10 16:51 Zenith_Hugh 阅读(224) 评论(0) 推荐(0) 编辑
摘要:Question from multiprocessing import Process, Queue 解释下这个多进程 Answer from multiprocessing import Process, Queue 是用于多进程处理的模块。 详细解释 多进程:multiprocessing 模 阅读全文
posted @ 2024-09-06 15:11 Zenith_Hugh 阅读(113) 评论(0) 推荐(0) 编辑
摘要:在 Python 中,A(object) 和 A 的区别涉及到类的继承和类的定义方式。 继承的区别: A(object) 表示 A 类继承自 object 类。这是在 Python 2 中引入新式类的写法,是显式地继承自基类 object。在 Python 3 中,所有的类都隐式继承自 object 阅读全文
posted @ 2023-12-14 11:55 Zenith_Hugh 阅读(75) 评论(0) 推荐(0) 编辑
摘要:pip install fake-useragent 以下是一段爬取百度图片的脚本: # -*- coding: utf-8 -*- """ Filename : spider_image_baidu.py Description: Spider - get images from baidu "" 阅读全文
posted @ 2023-06-19 11:04 Zenith_Hugh 阅读(57) 评论(0) 推荐(0) 编辑
摘要:[python 常用魔术方法](https://blog.csdn.net/hymn1993/article/details/124785641) [super().__init__() 有什么用?](https://www.cnblogs.com/ltkekeli1229/p/15651923.h 阅读全文
posted @ 2023-06-02 10:49 Zenith_Hugh 阅读(6) 评论(0) 推荐(0) 编辑
摘要:代码: import pandas as pd import glob target_path = 'Dataset/target.csv' cat_list = glob.glob('Dataset/cat/*csv') for index, cat_csv in enumerate(cat_li 阅读全文
posted @ 2022-12-20 00:21 Zenith_Hugh 阅读(61) 评论(0) 推荐(0) 编辑
摘要:#### 1. 推理脚本参数解析 脚本位置:https://github.com/ultralytics/yolov5/blob/master/detect.py 本文目的:通过学习该脚本,让我们可以自己编写别的项目的推理脚本。 主函数: if __name__ == "__main__": # 定 阅读全文
posted @ 2022-12-09 15:29 Zenith_Hugh 阅读(1064) 评论(0) 推荐(0) 编辑
摘要:1. python 文档 https://geek-docs.com/python https://geek-docs.com/python-samples 2. 边缘计算 https://www.cnblogs.com/showmeai/p/16627579.html 阅读全文
posted @ 2022-08-29 11:35 Zenith_Hugh 阅读(38) 评论(0) 推荐(0) 编辑
摘要:本文也算是一个小积累。 前提:使用python 写入json并追加内容。 错误实现: with open(os.path.join(annotations_path, 'data.json'), 'a') as f: pass 这样会相当于写入多个字典。可以写入,但无法使用如下代码读取: with 阅读全文
posted @ 2022-08-11 10:29 Zenith_Hugh 阅读(1964) 评论(0) 推荐(0) 编辑
摘要:1. 位置参数 调用函数时传入实际参数的数量和位置都必须和定义函数时保持一致。 2. 关键字参数 好处:不用记住形参位置。 所谓关键字就是“键-值”绑定,调用函数时,进行传递。 特点:位置参数和关键字参数混合传参时,位置参数必须在关键字参数的前面,关键字参数之间不存在先后顺序。 3. 默认参数 好处 阅读全文
posted @ 2020-11-17 10:02 Zenith_Hugh 阅读(123) 评论(0) 推荐(0) 编辑
摘要:1. 调用函数时,实参会传递给形参,叫做参数传递。 2. 根据实际参数的类型不同,函数参数的传递方式可分为 2 种,分别为值传递和引用(地址)传递: 值传递:传递的实参类型为不可变类型(字符串、数字、元组);对象本身不允许修改,数值的修改实际上是让变量指向了一个新的对象。 引用(地址)传递:传递的实 阅读全文
posted @ 2020-11-16 14:54 Zenith_Hugh 阅读(342) 评论(0) 推荐(0) 编辑
摘要:1. 什么是函数? 同数学中的函数,无非是输入-->处理-->输出。 2. 使用函数的好处? (1)可以重复调用,减少重复代码; (2)封装好,使用接口即可; (3)程序模块化。 3. Python具有内置函数,如:input()、print()、len()、range()等等。还允许自定义函数。 阅读全文
posted @ 2020-09-30 11:42 Zenith_Hugh 阅读(74) 评论(0) 推荐(0) 编辑

喜欢请打赏

扫描二维码打赏

微信打赏

点击右上角即可分享
微信分享提示