【Django】4 Django模型

每个模型是一个Python 类,集成django.db.models.Modle类

该模型的每个属性表示一个数据库表字段

通过API 自动生成数据库访问 .../sign/modles.py 文件,通过模型完成表创建。

 TypeError: ForeignKey.__init__() missing 1 required positional argument: 'on_delete'

在创建一个新模型时 ,出现错误TypeError: ForeignKey.__init__() missing 1 required positional argument: ‘on_delete‘_爱吃龙虾的小黑的博客-CSDN博客

E:\data\python\djaongo_prj\guest>  python manage.py makeigrations sign
Traceback (most recent call last):File "E:\data\python\djaongo_prj\guest\manage.py", line 21, in <module>main()File "E:\data\python\djaongo_prj\guest\manage.py", line 17, in mainexecute_from_command_line(sys.argv)File "D:\software\python3\anconda3\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_lineutility.execute()File "D:\software\python3\anconda3\Lib\site-packages\django\core\management\__init__.py", line 416, in executedjango.setup()File "D:\software\python3\anconda3\Lib\site-packages\django\__init__.py", line 24, in setupapps.populate(settings.INSTALLED_APPS)File "D:\software\python3\anconda3\Lib\site-packages\django\apps\registry.py", line 116, in populateapp_config.import_models()File "D:\software\python3\anconda3\Lib\site-packages\django\apps\config.py", line 269, in import_modelsself.models_module = import_module(models_module_name)File "D:\software\python3\python310\lib\importlib\__init__.py", line 126, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "<frozen importlib._bootstrap>", line 1050, in _gcd_importFile "<frozen importlib._bootstrap>", line 1027, in _find_and_loadFile "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 688, in _load_unlockedFile "<frozen importlib._bootstrap_external>", line 883, in exec_moduleFile "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removedFile "E:\data\python\djaongo_prj\guest\sign\models.py", line 20, in <module>class Guest(models.Model):File "E:\data\python\djaongo_prj\guest\sign\models.py", line 21, in Guestevent = models.ForeignKey(Event)  # 关联发布会id
TypeError: ForeignKey.__init__() missing 1 required positional argument: 'on_delete'

 必须要设置级联删除,也就是当你删除一条信息时,会级联的删除所有和这一条信息对应的另一张表的多个信息,也就是指定on_delete=models.CASCADE

event = models.ForeignKey(Event,on_delete=models.CASCADE)  # 关联发布会id

# 嘉宾
class Guest(models.Model):event = models.ForeignKey(Event,on_delete=models.CASCADE)  # 关联发布会idrealname = models.CharField(max_length=64)  # 姓名phone = models.CharField(max_length=16)  # 手机号email = models.EmailField()  # 邮箱sign = models.BooleanField()  # 签到状态create_time = models.DateTimeField(auto_now=True)  # 创建时间(自动获取当前时间)class Meta:unique_together = ('phone', 'event')def __str__(self):return self.realname

 python manage.py makemigrations sign

E:\data\python\djaongo_prj\guest>  python manage.py makemigrations sign
System check identified some issues:WARNINGS:
sign.Event: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.HINT: Configure the DEFAULT_AUTO_FIELD setting or the SignConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
sign.Guest: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.HINT: Configure the DEFAULT_AUTO_FIELD setting or the SignConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
Migrations for 'sign':sign\migrations\0001_initial.py- Create model Event- Create model Guest

  python manage.py migrate

E:\data\python\djaongo_prj\guest>  python manage.py migrate
System check identified some issues:WARNINGS:
sign.Event: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.HINT: Configure the DEFAULT_AUTO_FIELD setting or the SignConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
sign.Guest: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.HINT: Configure the DEFAULT_AUTO_FIELD setting or the SignConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
Operations to perform:Apply all migrations: admin, auth, contenttypes, sessions, sign
Running migrations:Applying auth.0012_alter_user_first_name_max_length... OKApplying sign.0001_initial... OKE:\data\python\djaongo_prj\guest>

admin  后台 管理

from django.contrib import admin# Register your models here.
#  admin 后台管理  创建的发布会和嘉宾表示同样可以通过Admin 后台管理
from  django.contrib  import  admin
from  sign.models import   Event ,Guest# Register your models here.
class EventAdmin(admin.ModelAdmin):list_display = ['name', 'status', 'start_time','id']search_fields = ['name']    # 搜索功能list_filter = ['status']    # 过滤器class GuestAdmin(admin.ModelAdmin):list_display = ['realname', 'phone','email','sign','create_time','event_id']list_display_links = ('realname', 'phone') # 显示链接search_fields = ['realname','phone']       # 搜索功能list_filter = ['sign']                 # 过滤器admin.site.register(Event, EventAdmin)
admin.site.register(Guest, GuestAdmin)

Microsoft Windows [版本 10.0.19045.3448]
(c) Microsoft Corporation。保留所有权利。E:\data\python\djaongo_prj\guest>python   manage.py shell
Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.10.0 -- An enhanced Interactive Python. Type '?' for help.In [1]:In [1]:In [1]: from sign.models import Event,GuestIn [2]: Event.objects.all()
Out[2]: <QuerySet [<Event: 小米5发布会>]>In [3]:

from sign.models import Event,Guest  导入模块

 Event.objects.all()   所有对象

配置 MySQL  

 pip  install pymysql

数据库创建表

报错 [Err] 1055 - Expression #1 of ORDER BY

[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated_Ricardo · M · YUAN的博客-CSDN博客

 

在配置文件的末尾加上这段代码:
[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

 

CREATE TABLE `sign_event` (`id` int NOT NULL AUTO_INCREMENT,`name` varchar(50) DEFAULT NULL COMMENT '名称',`limit` int DEFAULT NULL COMMENT 'limit',`status` varchar(1) DEFAULT '1' COMMENT '状态   0:隐藏   1:显示',`address` varchar(500) DEFAULT NULL COMMENT '地址',start_time DATE,create_time DATE,PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COMMENT='系统配置信息表';
CREATE TABLE `sign_guest` (`event_id` int NOT NULL ,`realname` varchar(50) DEFAULT NULL COMMENT '名称',`phone` varchar(11) COMMENT '手机号',`email` varchar(50) ,`sign` VARCHAR(1) DEFAULT '1' COMMENT '状态   0:隐藏   1:显示',create_time DATE,PRIMARY KEY (`event_id`,`phone`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COMMENT='嘉宾表';

insert into  sign_guest(realname,phone,email,sign,event_id,create_time)values("tom","12344444","1111@qq.com",1,123456,now())


select * from sign_guest

 

from pymysql import cursors, connect# 连接数据库
conn = connect(host='192.168.56.10', user='root', password='root',db='guest', charset='utf8mb4', cursorclass=cursors.DictCursor)try:with conn.cursor() as cursors:# 创建嘉宾数据sql = 'insert into  sign_guest(realname,phone,email,sign,event_id,create_time)values("tom2","12344444","1111@qq.com",1,123456,now())'cursors.execute(sql)conn.commit()with conn.cursor() as cursor:# 查询sql = "select  *  from sign_guest where phone=%s"cursor.execute(sql, ('12344444',))res = cursor.fetchone()print(res)
finally:conn.close()

 

 Django 连接 mysql 


DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3','NAME': os.path.join(BASE_DIR, 'db.sqlite3'),}
}

 

 

 

import pymysql
pymysql.install_as_MySQLdb()"""
如果你使用pymysql驱动的话,上面两行必须添加。
"""

 

E:\data\python\djaongo_prj\guest> python  manage.py migrate
Traceback (most recent call last):File "E:\data\python\djaongo_prj\guest\manage.py", line 21, in <module>main()File "E:\data\python\djaongo_prj\guest\manage.py", line 17, in mainexecute_from_command_line(sys.argv)File "D:\software\python3\anconda3\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_lineutility.execute()File "D:\software\python3\anconda3\Lib\site-packages\django\core\management\__init__.py", line 436, in executeself.fetch_command(subcommand).run_from_argv(self.argv)File "D:\software\python3\anconda3\Lib\site-packages\django\core\management\base.py", line 412, in run_from_argvself.execute(*args, **cmd_options)File "D:\software\python3\anconda3\Lib\site-packages\django\core\management\base.py", line 458, in executeoutput = self.handle(*args, **options)File "D:\software\python3\anconda3\Lib\site-packages\django\core\management\base.py", line 106, in wrapperres = handle_func(*args, **kwargs)File "D:\software\python3\anconda3\Lib\site-packages\django\core\management\commands\migrate.py", line 100, in handleself.check(databases=[database])File "D:\software\python3\anconda3\Lib\site-packages\django\core\management\base.py", line 485, in checkall_issues = checks.run_checks(File "D:\software\python3\anconda3\Lib\site-packages\django\core\checks\registry.py", line 88, in run_checksnew_errors = check(app_configs=app_configs, databases=databases)File "D:\software\python3\anconda3\Lib\site-packages\django\core\checks\model_checks.py", line 36, in check_all_modelserrors.extend(model.check(**kwargs))File "D:\software\python3\anconda3\Lib\site-packages\django\db\models\base.py", line 1558, in check*cls._check_indexes(databases),File "D:\software\python3\anconda3\Lib\site-packages\django\db\models\base.py", line 2002, in _check_indexesconnection.features.supports_expression_indexesFile "D:\software\python3\anconda3\Lib\site-packages\django\utils\functional.py", line 57, in __get__res = instance.__dict__[self.name] = self.func(instance)File "D:\software\python3\anconda3\Lib\site-packages\django\db\backends\mysql\features.py", line 317, in supports_expression_indexesnot self.connection.mysql_is_mariadbFile "D:\software\python3\anconda3\Lib\site-packages\django\utils\functional.py", line 57, in __get__res = instance.__dict__[self.name] = self.func(instance)File "D:\software\python3\anconda3\Lib\site-packages\django\db\backends\mysql\base.py", line 439, in mysql_is_mariadbreturn "mariadb" in self.mysql_server_info.lower()File "D:\software\python3\anconda3\Lib\site-packages\django\utils\functional.py", line 57, in __get__res = instance.__dict__[self.name] = self.func(instance)File "D:\software\python3\anconda3\Lib\site-packages\django\db\backends\mysql\base.py", line 425, in mysql_server_inforeturn self.mysql_server_data["version"]File "D:\software\python3\anconda3\Lib\site-packages\django\utils\functional.py", line 57, in __get__res = instance.__dict__[self.name] = self.func(instance)File "D:\software\python3\anconda3\Lib\site-packages\django\db\backends\mysql\base.py", line 399, in mysql_server_datawith self.temporary_connection() as cursor:File "D:\software\python3\python310\lib\contextlib.py", line 135, in __enter__return next(self.gen)File "D:\software\python3\anconda3\Lib\site-packages\django\db\backends\base\base.py", line 705, in temporary_connectionwith self.cursor() as cursor:File "D:\software\python3\anconda3\Lib\site-packages\django\utils\asyncio.py", line 26, in innerreturn func(*args, **kwargs)File "D:\software\python3\anconda3\Lib\site-packages\django\db\backends\base\base.py", line 330, in cursorreturn self._cursor()File "D:\software\python3\anconda3\Lib\site-packages\django\db\backends\base\base.py", line 306, in _cursorself.ensure_connection()File "D:\software\python3\anconda3\Lib\site-packages\django\utils\asyncio.py", line 26, in innerreturn func(*args, **kwargs)File "D:\software\python3\anconda3\Lib\site-packages\django\db\backends\base\base.py", line 289, in ensure_connectionself.connect()File "D:\software\python3\anconda3\Lib\site-packages\django\utils\asyncio.py", line 26, in innerreturn func(*args, **kwargs)File "D:\software\python3\anconda3\Lib\site-packages\django\db\backends\base\base.py", line 272, in connectself.init_connection_state()File "D:\software\python3\anconda3\Lib\site-packages\django\db\backends\mysql\base.py", line 257, in init_connection_statesuper().init_connection_state()File "D:\software\python3\anconda3\Lib\site-packages\django\db\backends\base\base.py", line 239, in init_connection_stateself.check_database_version_supported()File "D:\software\python3\anconda3\Lib\site-packages\django\db\backends\base\base.py", line 214, in check_database_version_supportedraise NotSupportedError(
django.db.utils.NotSupportedError: MySQL 8 or later is required (found 5.7.36).E:\data\python\djaongo_prj\guest>

 

django.db.utils.NotSupportedError: MySQL 8 or later is required (found 5.7.36).

django.db.utils.NotSupportedError: MySQL 8 or later is required (found 5.7.2)简单快速的解决办法_疯狂的小强呀的博客-CSDN博客

这个问题是说我们的Django框架版本比较新,已经不支持MySQL老版本5.7.2了,MySQL8或者更新的版本才是我们需要的或者说匹配的。

解决方案

从问题出发的解决方案有两个,①卸载老版本的MySQL,安装项目支持的新版本 ②降低Django框架的版本

pip uninstall django 

pip install django==2.1.13 

 要重启pycharm

Error: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。

Django-解决报错Error: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。_Python454的博客-CSDN博客 

 E:\data\python\djaongo_prj\guest>netstat -aon|findstr "8000"
  TCP    0.0.0.0:8000           0.0.0.0:0              LISTENING       14756
  UDP    0.0.0.0:8000           *:*

PID =14756

任务管理器 详细信息

 

 

D:\software\python3\python310\python.exe E:/data/python/djaongo_prj/guest/manage.py runserver 127.0.0.1:8001
D:\software\python3\anconda3\Lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-servicefrom . import _distributor_init
D:\software\python3\anconda3\Lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-servicefrom . import _distributor_init
Performing system checks...System check identified no issues (0 silenced).You have 16 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions, sign.
Run 'python manage.py migrate' to apply them.
October 02, 2023 - 21:57:38
Django version 2.1.13, using settings 'guest.settings'
Starting development server at http://127.0.0.1:8001/
Quit the server with CTRL-BREAK.

 设置  runserver 127.0.0.1:8001

 启动成功

 删除 数据库中 sign_event  表

python  manage.py migrate

  File "D:\software\python3\anconda3\Lib\site-packages\pymysql\protocol.py", line 221, in raise_for_errorerr.raise_mysql_exception(self._data)File "D:\software\python3\anconda3\Lib\site-packages\pymysql\err.py", line 143, in raise_mysql_exceptionraise errorclass(errno, errval)
django.db.utils.OperationalError: (1050, "Table 'sign_event' already exists")E:\data\python\djaongo_prj\guest>python  manage.py migrate
Operations to perform:Apply all migrations: admin, auth, contenttypes, sessions, sign
Running migrations:Applying sign.0001_initial... OKE:\data\python\djaongo_prj\guest>

重新生成后台管理admin

 python manage.py createsuperuser

E:\data\python\djaongo_prj\guest>python manage.py createsuperuser
Username (leave blank to use 'administrator'): admin
Email address: 11111@qq.com
Password:
Password (again):
Superuser created successfully.

 http://127.0.0.1:8001/admin/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/147307.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

【算法训练-贪心算法】一 买卖股票的最佳时机II

废话不多说&#xff0c;喊一句号子鼓励自己&#xff1a;程序员永不失业&#xff0c;程序员走向架构&#xff01;本篇Blog的主题是【贪心算法】&#xff0c;使用【数组】这个基本的数据结构来实现&#xff0c;这个高频题的站点是&#xff1a;CodeTop&#xff0c;筛选条件为&…

【小沐学前端】Node.js实现基于Protobuf协议的UDP通信(UDP/TCP)

文章目录 1、简介1.1 node1.2 Protobuf 2、下载和安装2.1 node2.2 Protobuf2.2.1 安装2.2.2 工具 3、node 代码示例3.1 HTTP3.2 UDP单播3.4 UDP广播 4、Protobuf 代码示例4.1 例子: awesome.proto4.1.1 加载.proto文件方式4.1.2 加载.json文件方式4.1.3 加载.js文件方式 4.2 例…

idea Springboot在线商城系统VS开发mysql数据库web结构java编程计算机网页源码maven项目

一、源码特点 springboot 在线商城系统是一套完善的信息系统&#xff0c;结合springboot框架和bootstrap完成本系统&#xff0c;对理解JSP java编程开发语言有帮助系统采用springboot框架&#xff08;MVC模式开发&#xff09;&#xff0c;系统具有 完整的源代码和数据库&…

多目标平衡优化器黏菌算法(MOEOSMA)求解CEC2020多模式多目标优化

多目标平衡优化器黏菌算法&#xff08;MOEOSMA&#xff09;比现有的多目标黏菌算法具有更好的优化性能。在MOEOSMA中&#xff0c;动态系数用于调整勘探和开采趋势。采用精英存档机制来促进算法的收敛性。使用拥挤距离法来保持Pareto前沿的分布。采用平衡池策略模拟黏菌的协同觅…

Redis持久化、主从与哨兵架构详解

文章目录 一、RDB、AOF及混合持久化详解RDB快照&#xff08;snapshot&#xff09;bgsave的写时复制(COW)机制save与bgsave对比&#xff1a; AOF&#xff08;append-only file&#xff09;AOF重写 RDB 和 AOF &#xff0c;我应该用哪一个&#xff1f;Redis 4.0 混合持久化 二、R…

IDEA的使用

文章目录 1.IDEA配置1.1 idea界面说明1.2 git1.3 JDK1.4 maven1.5 Tomcat1.6 idea设置编码格式1.7 vscodenodejs1.8 windows下安装redis 2. IDEA问题2.1 setAttribute方法爆红2.2 idea cannot download sources解决办法2.3 springboot项目跑起来不停run 3. vscode3.1 vscode显示…

springcloud:四、nacos介绍+启动+服务分级存储模型/集群+NacosRule负载均衡

nacos介绍 nacos是阿里巴巴提供的SpringCloud的一个组件&#xff0c;算是eureka的替代品。 nacos启动 安装过程这里不再赘述&#xff0c;相关安装或启动的问题可以见我的另一篇博客&#xff1a; http://t.csdn.cn/tcQ76 单价模式启动命令&#xff1a;进入bin目录&#xff0…

Ant-Design-Vue:a-range-picker组件国际化配置

在使用Ant-Design-Vue中的时间范围选择器开发个人项目时&#xff0c;发现默认显示为英文。如何解决呢&#xff1f; date-picker分类 Antd-Vue提供了DatePicker、MonthPicker、RangePicker、WeekPicker 几种类型的时间选择器&#xff0c;分别用于选择日期、月份、日期范围、周范…

win10系统任务栏图标变成白色的解决办法

我平时都是用滴答清单进行管理这个自己的日程代办的&#xff0c;但是今天打开的时候发现这个快捷方式突然变成纯白色的了&#xff0c;重启电脑之后&#xff0c;这个图标的样式仍然没有变化。上网查找解决办法之后&#xff0c;终于搞好了&#xff0c;于是就有了下面的教程。 为什…

Android studio “Layout Inspector“工具在Android14 userdebug设备无法正常使用

背景描述 做rom开发的都知道&#xff0c;“Layout Inspector”和“Attach Debugger to Android Process”是studio里很好用的工具&#xff0c;可以用来查看布局、调试系统进程&#xff08;比如setting、launcher、systemui&#xff09;。 问题描述 最进刚开始一个Android 14…

(Note)机器学习面试题

机器学习 1.两位同事从上海出发前往深圳出差&#xff0c;他们在不同时间出发&#xff0c;搭乘的交通工具也不同&#xff0c;能准确描述两者“上海到深圳”距离差别的是&#xff1a; A.欧式距离 B.余弦距离 C.曼哈顿距离 D.切比雪夫距离 S:D 1. 欧几里得距离 计算公式&#x…

机器学习之SGD, Batch, and Mini Batch的简单介绍

文章目录 总述SGD(Stochastic Gradient Descent)(随机梯度下降&#xff09;Batch &#xff08;批量&#xff09;mini Batch (迷你批量&#xff09; 总述 SGD, Batch, and Mini Batch是可用于神经网络的监督学习计算权重更新的方案&#xff0c;即∆wij。 SGD(Stochastic Gradi…

【STM32】IAP升级03关闭总中断,检测栈顶指针

IAP升级方法 IAP升级时需要关闭总中断 TM32在使用时有时需要禁用全局中断&#xff0c;比如MCU在升级过程中需禁用外部中断&#xff0c;防止升级过程中外部中断触发导致升级失败。 ARM MDK中提供了如下两个接口来禁用和开启总中断&#xff1a; __disable_irq(); // 关闭总中…

emacs怎么安装插件

2023年9月26日&#xff0c;周二下午 不得不说&#xff0c;emacs安装插件确实要比vim要方便 虽然我曾经说过要只用vim&#xff0c;但vim安装插件起来太麻烦了 目录 Linux下Emacs的配置文件位置包管理器elpa怎么给elpa换源罗列可安装的插件怎么搜索插件怎么安装插件配置插件 L…

什么是FOSS

FOSS 是指 自由和开放源码软件(Free and Open Source Software)。这并不意味着软件是免费的。它意味着软件的源代码是开放的&#xff0c;任何人都可以自由使用、研究和修改代码。这个原则允许人们像一个社区一样为软件的开发和改进做出贡献。

CentOS密码重置

背景&#xff1a; 我有一个CentOS虚拟机&#xff0c;但是密码忘记了&#xff0c;偶尔记起可以重置密码&#xff0c;于是今天尝试记录一下&#xff0c;又因为我最近记性比较差&#xff0c;所以必须要记录一下。 过程&#xff1a; 1、在引导菜单界面&#xff08;grub&#xff…

如何实现电脑语音输入功能?

现在的手机都具备语音输入功能&#xff0c;并且识别率非常高&#xff0c;语音输入是目前最快速的文字输入方式&#xff0c;但是电脑上却无语音输入的功能&#xff0c;那么如何实现在电脑端也可进行语音输入的梦想呢&#xff1f;现在介绍一款小工具“书剑电脑语音输入法”&#…

java并发编程 守护线程 用户线程 main

经常使用线程&#xff0c;没有对守护线程和用户线程的区别做彻底了解 下面写4个例子来验证一下 源码如下 /* Whether or not the thread is a daemon thread. */ private boolean daemon false;/*** Marks this thread as either a {linkplain #isDaemon daemon} thread*…

Python|OpenCV-如何给目标图像添加边框(7)

前言 本文是该专栏的第7篇,后面将持续分享OpenCV计算机视觉的干货知识,记得关注。 在使用opencv处理图像的时候,会不可避免的对图像的一些具体区域进行一些操作。比如说,想要给目标图像创建一个围绕图像的边框。简单的来说,就是在图片的周围再填充一个粗线框。具体效果,…

OpenCV实现视频的读取、显示、保存

目录 1&#xff0c;从文件中读取视频并播放 1.2代码实现 1.3效果展示 2&#xff0c;保存视频 2.1 代码实现 2.2 结果展示 1&#xff0c;从文件中读取视频并播放 在OpenCV中我们需要获取一个视频&#xff0c;需要创建一个VideoCapture对象,指定你要读取的视频文件&am…