Python-VBA函数之旅-type函数

news2024/10/6 4:03:46

目录

一、type函数的常见应用场景

二、type函数使用注意事项

三、如何用好type函数?

1、type函数:

1-1、Python:

1-2、VBA:

2、推荐阅读:

个人主页: https://myelsa1024.blog.csdn.net/

一、type函数的常见应用场景

        type函数在Python中有多个实际应用场景,尽管它主要用于获取对象的类型,但在某些特定情况下,它也能提供重要的信息或用于编程的某些方面,其常见的应用场景有:

1、类型检查: 当你需要确保某个变量或对象具有特定的类型时,可以使用type()函数进行检查,这在编写函数或方法时特别有用,尤其是当函数需要特定类型的参数时。

2、动态类型判断:在某些情况下,你可能需要根据对象的类型来执行不同的操作,使用type()函数可以帮助你实现这种动态类型判断。

3、反射和元编程:在需要编写能够处理不同类型对象的通用代码时,可以使用type()函数和相关的元编程技术。例如,你可以检查一个对象的类型,并基于该类型调用不同的方法或执行不同的操作。

4、注册和类型映射:在构建大型系统时,可能需要将对象类型映射到特定的处理函数或类,type()函数可以用于实现这样的类型到行为的映射。

5、工厂函数和类工厂:在需要基于输入参数动态创建不同类型对象的情况下,可以使用type()函数作为类工厂,这在实现复杂的工厂模式或元编程时可能很有用。

6、调试和日志记录:在开发过程中,type()函数可以帮助你确定变量的实际类型,这在调试或记录对象状态时可能很有用。

7、与其他类型系统交互:当与需要明确类型信息的外部系统或库交互时,type()函数可以帮助你提供正确的类型信息。

8、与内建类型进行比较:有时你可能想要检查一个对象是否是某个特定的内建类型(如int, str, list等),虽然isinstance()函数是更推荐的做法,但type()函数也可以用于此目的。

二、type函数使用注意事项

        在Python中使用type()函数时,请注意以下几点:

1、避免直接使用type()函数进行类型检查:虽然type()函数可以用来检查对象的类型,但在实践中,更推荐使用isinstance()函数来进行类型检查,这是因为isinstance()会考虑子类关系,而type()则不会,如果你的代码期望接受某个类或其子类的实例,使用isinstance()会更加灵活和健壮。

2、动态类型与静态类型:Python是一种动态类型语言,这意味着变量的类型可以在运行时改变,因此,过度依赖type()函数进行类型检查可能并不符合Python的哲学,在编写Python代码时,应该尽量利用动态类型的优势,而不是试图强制所有变量都保持固定的类型。

3、使用type()创建新类型:虽然type()函数可以用于在运行时动态地创建新的类型,但这种用法在Python中并不常见,Python提供了更直观和易于理解的class语法来定义新的类型,这在大多数情况下都是首选的方法。

4、不要修改内建类型的 `__name__` 或 `__class__` 属性:尽管Python允许你修改对象的属性,但你应该避免修改内建类型或对象的 `__name__` 或 `__class__` 属性,这些属性在Python的内部机制中扮演着重要的角色,修改它们可能会导致不可预测的行为或错误。

5、理解type()函数和class的关系:在Python中,type()函数实际上是一个内建的元类,它负责创建和管理类,当你使用class关键字定义一个类时,Python会自动使用type()作为元类来创建这个类,理解这个关系有助于你更深入地理解Python的类系统。

6、处理NoneType:当你使用type()函数检查一个值为None的变量时,它将返回<class 'NoneType'>,确保在代码中正确处理这种情况,特别是当你期望某个变量可能是None时。

7、注意类型注解(从Python 3.5开始):虽然类型注解(如 `def foo(x: int) -> str:`)并不会改变Python 的动态类型特性,但它们为代码提供了额外的类型信息;类型注解主要用于文档、类型检查和可能的静态类型分析,type()函数与类型注解没有直接关系,但在编写和阅读带有类型注解的代码时,你应该意识到这些注解的存在和用途。

三、如何用好type函数?

        type()函数在Python中用于获取对象的类型,这个函数非常有用,尤其是在你想了解某个对象的类型,或者你想根据对象的类型来执行不同的操作时。为了用好type()函数,请遵循以下建议和方法:

1、获取对象的类型:使用type()函数可以轻松地获取任何对象的类型。

2、判断对象的类型:你可以使用type()函数来判断一个对象是否属于特定的类型,但是,通常建议使用内置的isinstance()函数来进行类型检查,因为它支持子类检查(即如果对象是某个类的子类的实例,isinstance()也会返回True)。

3、在动态类型系统中使用:Python是一种动态类型语言,但type()函数仍然在某些情况下很有用。例如,你可能有一个函数,它接受一个对象并根据该对象的类型执行不同的操作。

4、与isinstance()函数结合使用:虽然type()函数可以用于类型检查,但isinstance()函数通常是更好的选择,但是,你可以结合使用type()和isinstance()两个函数来检查对象是否属于特定的元组或集合中的类型。

​​​​​​​

1、type函数:
1-1、Python:
# 1.函数:type
# 2.功能:
# 2-1、一个参数:用于获取对象的类型
# 2-2、多个参数:用于获取新的类型对象
# 3.语法:
# 3-1、type(object)
# 3-2、type(name, bases, dict, **kwds)
# 4.参数:
# 4-1、object:想要检查其类型的对象或变量
# 4-2、相关参数说明如下:
# 4-2-1、name:一个字符串,表示新类型的名称
# 4-2-2、bases:一个元组,表示新类型所继承的父类元组的集合(一个或多个)
# 4-2-3、dict:一个字典,其中包含定义新类型的属性的键值对
# 4-2-4、**kwds:一个额外的关键字参数,但在创建类时通常不使用
# 5.返回值:
# 5-1、一个参数:返回对象的类型
# 5-2、多个参数:返回新的类型对象
# 6.说明:
# 7.示例:
# 用dir()函数获取该函数内置的属性和方法
print(dir(type))
# ['__abstractmethods__', '__annotations__', '__base__', '__bases__', '__basicsize__', '__call__', '__class__',
# '__delattr__', '__dict__', '__dictoffset__', '__dir__', '__doc__', '__eq__', '__flags__', '__format__', '__ge__',
# '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__instancecheck__', '__itemsize__',
# '__le__', '__lt__', '__module__', '__mro__', '__name__', '__ne__', '__new__', '__or__', '__prepare__', '__qualname__', '__reduce__',
# '__reduce_ex__', '__repr__', '__ror__', '__setattr__', '__sizeof__', '__str__', '__subclasscheck__', '__subclasses__', '__subclasshook__',
# '__text_signature__', '__weakrefoffset__', 'mro']

# 用help()函数获取该函数的文档信息
help(type)

# 应用一:类型检查
# 示例1:使用type()进行类型检查
def check_type_with_type(obj, target_type):
    return type(obj) is target_type
# 示例
num = 123
print(check_type_with_type(num, int))  # 输出: True
string = "hello"
print(check_type_with_type(string, str))  # 输出: True
# 错误的类型检查(不建议)
print(check_type_with_type(string, list))  # 输出: False
# True
# True
# False

# 示例2:使用isinstance()进行类型检查(推荐)
def check_type_with_isinstance(obj, target_type):
    return isinstance(obj, target_type)
# 示例
num = 123
print(check_type_with_isinstance(num, int))  # 输出: True
string = "hello"
print(check_type_with_isinstance(string, str))  # 输出: True
# 检查子类
class MyList(list):
    pass
my_list = MyList([1, 2, 3])
print(check_type_with_isinstance(my_list, list))  # 输出: True
# True
# True
# True

# 应用二:动态类型判断
# 示例1:使用type()进行动态类型判断
def dynamic_type_check(obj):
    if type(obj) is int:
        print(f"The object is an integer with value: {obj}")
    elif type(obj) is str:
        print(f"The object is a string with value: '{obj}'")
    elif type(obj) is list:
        print(f"The object is a list with elements: {obj}")
    else:
        print(f"The object is of type: {type(obj)}")
# 示例
dynamic_type_check(123)  # 输出: The object is an integer with value: 123
dynamic_type_check("hello")  # 输出: The object is a string with value: 'hello'
dynamic_type_check([1, 2, 3])  # 输出: The object is a list with elements: [1, 2, 3]
dynamic_type_check(3.14)  # 输出: The object is of type: <class 'float'>
# The object is an integer with value: 123
# The object is a string with value: 'hello'
# The object is a list with elements: [1, 2, 3]
# The object is of type: <class 'float'>

# 示例2:使用isinstance()进行动态类型判断(推荐)
def dynamic_type_check_with_isinstance(obj):
    if isinstance(obj, int):
        print(f"The object is an integer or a subtype of integer with value: {obj}")
    elif isinstance(obj, str):
        print(f"The object is a string or a subtype of string with value: '{obj}'")
    elif isinstance(obj, list):
        print(f"The object is a list or a subtype of list with elements: {obj}")
    else:
        print(f"The object is of type: {type(obj)}")
# 示例,包括自定义类(子类)
class MyString(str):
    pass
my_string = MyString("custom string")
dynamic_type_check_with_isinstance(123)  # 输出: The object is an integer or a subtype of integer with value: 123
dynamic_type_check_with_isinstance("hello")  # 输出: The object is a string or a subtype of string with value: 'hello'
dynamic_type_check_with_isinstance(
    my_string)  # 输出: The object is a string or a subtype of string with value: 'custom string'
dynamic_type_check_with_isinstance(
    [1, 2, 3])  # 输出: The object is a list or a subtype of list with elements: [1, 2, 3]
dynamic_type_check_with_isinstance(3.14)  # 输出: The object is of type: <class 'float'>
# The object is an integer or a subtype of integer with value: 123
# The object is a string or a subtype of string with value: 'hello'
# The object is a string or a subtype of string with value: 'custom string'
# The object is a list or a subtype of list with elements: [1, 2, 3]
# The object is of type: <class 'float'>

# 应用三:反射和元编程
# 示例1:使用type()进行反射
class MyClass:
    def __init__(self, value):
        self.value = value
def reflect_on_object(obj):
    print(f"Object type: {type(obj)}")
    print(f"Object attributes: {dir(obj)}")
# 示例
obj = MyClass(42)
reflect_on_object(obj)
# Object type: <class '__main__.MyClass'>
# Object attributes: ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__',
# '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__',
# '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'value']

# 示例2:使用type()进行元编程
def create_class_dynamically(class_name, base_classes=(), attrs={}):
    return type(class_name, base_classes, attrs)
# 示例:动态创建一个类
DynamicClass = create_class_dynamically('DynamicClass', (),
                                        {'x': 10, 'y': 20, 'display': lambda self: print(self.x, self.y)})
# 实例化并调用方法
instance = DynamicClass()
instance.display()  # 输出: 10 20
# 验证类的属性
print(type(DynamicClass))  # 输出: <class 'type'>
print(DynamicClass.x)  # 输出: 10
# 10 20
# <class 'type'>
# 10

# 示例3:复杂的元编程示例--工厂函数创建类
def class_factory(class_name, class_attributes):
    methods = {k: v for k, v in class_attributes.items() if callable(v)}
    other_attrs = {k: v for k, v in class_attributes.items() if not callable(v)}
    def init_method(self, **kwargs):
        for key, value in other_attrs.items():
            setattr(self, key, value)
        for key, value in kwargs.items():
            setattr(self, key, value)
    class_dict = {'__init__': init_method}
    class_dict.update(methods)  # 将方法添加到类字典中
    return type(class_name, (object,), class_dict)
# 示例:使用工厂函数创建类
Person = class_factory('Person', {'name': 'placeholder',  # 这里使用一个占位符,将在初始化时设置
                                  'greet': lambda self: print(f"Hello, I'm {self.name}")})
# 实例化并调用方法
person = Person(name='John Doe', age=30)  # 在这里设置 name 属性
person.greet()  # 输出: Hello, I'm John Doe
print(person.name)  # 输出: John Doe
print(person.age)  # 输出: 30
# Hello, I'm John Doe
# John Doe
# 30

# 应用四:注册和类型映射
# 定义一个类型到处理函数的映射字典
type_registry = {}
# 注册类型的装饰器
def register_type(type_class):
    def decorator(func):
        type_registry[type_class] = func
        return func
    return decorator
# 一个处理int类型的函数
@register_type(int)
def handle_int(value):
    print(f"Handling integer: {value}")
# 一个处理str类型的函数
@register_type(str)
def handle_str(value):
    print(f"Handling string: {value}")
# 一个处理类型并调用相应处理函数的函数
def handle_value(value):
    value_type = type(value)
    if value_type in type_registry:
        type_registry[value_type](value)
    else:
        print(f"No handler for type {value_type}")
# 使用示例
handle_value(123)  # 输出: Handling integer: 123
handle_value("hello")  # 输出: Handling string: hello
handle_value(3.14)  # 输出: No handler for type <class 'float'>
# 如果需要,可以添加更多的类型处理函数
@register_type(float)
def handle_float(value):
    print(f"Handling float: {value}")
# 现在float类型也被处理了
handle_value(3.14)  # 输出: Handling float: 3.14
# Handling integer: 123
# Handling string: hello
# No handler for type <class 'float'>
# Handling float: 3.14

# 应用五:工厂函数和类工厂
# 示例1:工厂函数示例
class Animal:
    def __init__(self, name):
        self.name = name
    def speak(self):
        pass
class Dog(Animal):
    def speak(self):
        return "Woof!"
class Cat(Animal):
    def speak(self):
        return "Meow!"
def animal_factory(animal_type, name):
    if animal_type == 'dog':
        return Dog(name)
    elif animal_type == 'cat':
        return Cat(name)
    else:
        raise ValueError(f"Unsupported animal type: {animal_type}")
# 使用工厂函数
dog = animal_factory('dog', 'Buddy')
print(dog.speak())  # 输出: Woof!
cat = animal_factory('cat', 'Whiskers')
print(cat.speak())  # 输出: Meow!
# Woof!
# Meow!

# 示例2:类工厂示例
def class_factory(class_name, base_classes=(), class_attributes={}):
    return type(class_name, base_classes, class_attributes)
# 定义Animal类的通用属性和方法
def animal_init(self, name):
    self.name = name
def animal_speak(self):
    pass


AnimalAttributes = {
    'species': '',
    'num_legs': 0,
    '__init__': animal_init,
    'speak': animal_speak
}
# 使用类工厂创建一个新的类
DogClass = class_factory('Dog', (object,), {
    **AnimalAttributes,
    'species': 'dog',
    'num_legs': 4,
    'speak': lambda self: "Woof!"  # 或者定义一个名为dog_speak的函数,然后引用它
})
# 实例化新创建的类
dog = DogClass('Buddy')
print(dog.speak())  # 输出: Woof!
print(dog.species)  # 输出: dog
print(dog.num_legs)  # 输出: 4
# Woof!
# dog
# 4

# 应用六:调试和日志记录
# 示例1:基本的调试输出
def check_type(obj):
    print(f"The type of {obj} is: {type(obj)}")
# 使用示例
number = 123
string_value = "Hello, World!"
list_example = [1, 2, 3]
check_type(number)  # 输出: The type of 123 is: <class 'int'>
check_type(string_value)  # 输出: The type of Hello, World! is: <class 'str'>
check_type(list_example)  # 输出: The type of [1, 2, 3] is: <class 'list'>
# The type of 123 is: <class 'int'>
# The type of Hello, World! is: <class 'str'>
# The type of [1, 2, 3] is: <class 'list'>

# 示例2:使用logging模块记录类型信息
import logging
# 配置logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
def log_type(obj):
    logging.info(f"The type of {obj} is: {type(obj)}")
# 使用示例
number = 123
string_value = "Hello, World!"
log_type(number)  # 输出: 时间戳 - INFO - The type of 123 is: <class 'int'>
log_type(string_value)  # 输出: 时间戳 - INFO - The type of Hello, World! is: <class 'str'>
# 2024-05-13 22:47:10,127 - INFO - The type of 123 is: <class 'int'>
# 2024-05-13 22:47:10,127 - INFO - The type of Hello, World! is: <class 'str'>

# 示例3:在复杂函数中使用type()进行错误检查
import logging
def divide(a, b):
    if type(a) not in [int, float] or type(b) not in [int, float]:
        raise ValueError("Both a and b must be numbers.")
    if type(b) is int and b == 0:
        raise ValueError("Cannot divide by zero.")
    return a / b
try:
    result = divide(10, 2)
    print(result)  # 输出: 5.0
except ValueError as e:
    logging.error(e)
try:
    result = divide(10, "two")
except ValueError as e:
    logging.error(e)  # 输出: 时间戳 - ERROR - Both a and b must be numbers.
try:
    result = divide(10, 0)
except ValueError as e:
    logging.error(e)  # 输出: 时间戳 - ERROR - Cannot divide by zero.
# ERROR:root:Both a and b must be numbers.
# ERROR:root:Cannot divide by zero.
# 5.0

# 示例4:在面向对象编程中使用type()进行类型检查
import logging
class Animal:
    pass
class Dog(Animal):
    pass
def feed(animal):
    if not isinstance(animal, Animal):
        raise TypeError("animal must be an instance of Animal or its subclasses.")
    print(f"Feeding {type(animal).__name__}...")
dog = Dog()
feed(dog)  # 输出: Feeding Dog...
not_an_animal = "Not an animal"
try:
    feed(not_an_animal)
except TypeError as e:
    logging.error(e)  # 输出: 时间戳 - ERROR - animal must be an instance of Animal or its subclasses.
# ERROR:root:animal must be an instance of Animal or its subclasses.
# Feeding Dog...

# 应用七:与其他类型系统交互
# 示例1:使用type()进行条件导入
def load_module_based_on_type(obj):
    if type(obj) is int:
        import math  # 假设你需要math模块来处理整数
        print(math.sqrt(obj))
    elif type(obj) is str:
        import re  # 假设你需要re模块来处理字符串
        print(re.search(r'\d+', obj))  # 示例:查找字符串中的数字
    else:
        print("Unsupported type for module loading.")
load_module_based_on_type(9)  # 输出: 3.0(平方根)
load_module_based_on_type("abc123")  # 输出: <re.Match object; span=(3, 6), match='123'>
# 3.0
# <re.Match object; span=(3, 6), match='123'>

# 示例2:使用type()和自定义类型
class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age
def greet(entity):
    if type(entity) is Person:
        print(f"Hello, {entity.name}. You are {entity.age} years old.")
    else:
        print(f"Hello, but I don't know how to greet a {type(entity)}.")
p = Person("Myelsa", 18)
greet(p)
greet("Not a person")
# Hello, Myelsa. You are 18 years old.
# Hello, but I don't know how to greet a <class 'str'>.
1-2、VBA:
略,待后补。
2、推荐阅读:

2-1、Python-VBA函数之旅-isinstance()函数

Python算法之旅:Algorithms

Python函数之旅:Functions

个人主页: https://myelsa1024.blog.csdn.net/

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

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

相关文章

企业微信hook接口协议,ipad协议http,获取群成员列表简洁版

获取群成员列表简洁版 参数名必选类型说明uuid是String每个实例的唯一标识&#xff0c;根据uuid操作具体企业微信 请求示例 {"uuid":"3240fde0-45e2-48c0-90e8-cb098d0ebe43","roomid":10696052955016166 } 返回示例 {"data": {&q…

政安晨:【Keras机器学习示例演绎】(四十四)—— 使用序列到序列转换器实现英语到西班牙语的翻译

目录 简介 设置 下载数据 解析数据 文本数据矢量化 建立模型 训练我们的模型 解码测试句子 政安晨的个人主页&#xff1a;政安晨 欢迎 &#x1f44d;点赞✍评论⭐收藏 收录专栏: TensorFlow与Keras机器学习实战 希望政安晨的博客能够对您有所裨益&#xff0c;如有不足之…

智慧管家物业管理系统(小组项目)

目录 前言 一、项目介绍 1、目的和背景 2、项目主要内容 3、技术介绍 二、功能模块 1、重要文件结构 2、功能实现&#xff08;部分个人负责模块功能&#xff09; 2.1 展示房源信息页面 2.2 房屋详情页面 2.3 房源信息管理 三、功能模块页面 1、前台模块 2、后台…

使用vue3+ts+vite从零开始搭建bolg(五):layout(持续更新中)

五、layout搭建 5.1静态搭建 在src下创建如图文件夹 这里用logo举例&#xff0c;在scripts里export <script lang"ts">export default {name: Logo,}</script> 然后在layout里引入 //引入左侧菜单顶部用户信息 import Logo from ./logo/index.vue 接…

M-有效算法

在赛场上&#xff0c;脑子就两个字“二分”&#xff0c;一点思路都没&#xff0c;完全不知道二分谁&#xff0c;怎么二分&#xff0c;从哪入手。隐隐约约也知道要变换公式&#xff0c;可惜没坚持这个想法。脑子里全是把k分离出来&#xff0c;赛后看了题解才知道&#xff0c;应该…

Electron + GitHub Actions | 自动化流程详解(下)

自动化部署 上篇介绍了 Electron Forge 打包应用教程。在实际开发中&#xff0c;自动化是提升效率和产出质量的关键。本篇我们将详细介绍如何将构建和发布 Electron 应用的过程自动化。 代码挂在 GitHub 仓库上&#xff0c;如果有帮助&#xff0c;记得给仓库点个赞&#xff1a…

【ARM Cortex-M 系列 2.1 -- Cortex-M7 Debug system registers】

请阅读【嵌入式开发学习必备专栏】 文章目录 Debug system registers中断控制状态寄存器&#xff08;ICSR&#xff09;Debug Halting Control and Status Register, DHCSR Debug 寄存器DCRSR与DCRDRCPU 寄存器读操作CPU 寄存器写操作CPU 寄存器选择CPU 寄存器读写示例 调试故障…

【MQTT】paho.mqtt.cpp 库的 介绍、下载、交叉编译、MQTT客户端例子源码

&#x1f601;博客主页&#x1f601;&#xff1a;&#x1f680;https://blog.csdn.net/wkd_007&#x1f680; &#x1f911;博客内容&#x1f911;&#xff1a;&#x1f36d;嵌入式开发、Linux、C语言、C、数据结构、音视频&#x1f36d; ⏰发布时间⏰&#xff1a;2024-05-13 1…

盘他系列——oj!!!

1.Openjudge 网站: OpenJudge 2.洛谷 网站: 首页 - 洛谷 | 计算机科学教育新生态 3.环球OJ 网站: QOJ - QOJ.ac 4. 北京大学 OJ:Welcome To PKU JudgeOnline 5.自由OJ 网站: https://loj.ac/ 6.炼码 网站:LintCode 炼码 8.力扣 网站: 力扣 9.晴练网首页 - 晴练网

安科瑞AIM-D100-ES光伏储能系统直流绝缘监测仪

概述 AIM-D100-ES 型直流绝缘监测仪主要用于在线监测直流不接地系统正负极对地绝缘电阻&#xff0c;当绝缘电阻低于设定值时&#xff0c;能发出预警和报警信号。 产品可测 100-1500V 的直流系统&#xff0c;可应用于储能直流系统、电动汽车充电装置、UPS 供电系统、光伏直流系…

第十一届蓝桥杯大赛软件类决赛 Java C 组

文章目录 发现宝藏【考生须知】试题 A: 美丽的 2试题 B: 合数个数试题 C: 扩散试题 D: 阶乘约数试题 E: 本质上升序列试题 F 天干地支试题 G 皮亚诺曲线距离试题 H 蓝肽子序列试题 I: 画廊试题 J 答疑 发现宝藏 前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&a…

本地运行《使用AMD上的SentenceTransformers构建语义搜索》

Building semantic search with SentenceTransformers on AMD — ROCm Blogs 这篇博客解释了如何在Sentence Compression数据集上训练SentenceTransformers模型来执行语义搜索。使用BERT基础模型&#xff08;不区分大小写&#xff09;作为基础的变换器&#xff0c;并应用Huggi…

家居分类的添加、修改、逻辑删除和批量删除

文章目录 1.逻辑删除家居分类1.将之前的docker数据库换成云数据库2.树形控件增加添加和删除按钮1.找到控件2.粘贴四个属性到<el-tree 属性>3.粘贴两个span到<el-tree>标签里4.代码5.效果6.方法区新增两个方法处理添加和删除分类7.输出查看一下信息8.要求节点等级小…

Spring AI项目Open AI绘画开发指导

Spring AI项目创建 Spring AI简介创建Spring AI项目配置项目pom和application文件controller接口开发运行测试 Spring AI简介 Spring AI 是 AI 工程的应用框架。其目标是将 Spring 生态系统设计原则&#xff08;如可移植性和模块化设计&#xff09;应用于 AI&#xff0c;并推广…

自作聪明的AI? —— 信息处理和传递误区

一、背景 在人与人的信息传递中有一个重要问题——由于传递人主观处理不当&#xff0c;导致信息失真或产生误导。在沟通交流中&#xff0c;确实存在“自作聪明”的现象&#xff0c;即传递人在转述或解释信息时&#xff0c;根据自己对信息的理解、经验以及个人意图进行了过多的…

SpringSecurity6实现动态权限,rememberMe、OAuth2.0授权登录,退出登录等功能

本文章对应视频可在B站查看SpringSecurity6对应视频教程&#xff0c;记得三连哦&#xff0c;这对我很重要呢&#xff01; 温馨提示&#xff1a;视频与文章相辅相成&#xff0c;结合学习效果更强哦&#xff01; 系列文章链接 1、初识SpringSecurity&#xff0c;认识主流Java权限…

AI+文旅|当智慧遇见风景,感受文旅新体验

今年的五一假期,公众出游热度持续升温&#xff0c;全国多地景区再现“人山人海”&#xff0c;在这样的背景下&#xff0c;促使文旅行业不断通过数字化手段&#xff0c;提升旅游体验质量、探索新的服务方式&#xff0c;AI技术的加入为旅游业带来了革命性的变化。智能导游、智能推…

FOTS:一种用于机器人操作技能Sim2Real学习的快速光学触觉仿真器

类 GelSight的视触觉传感器具有高分辨率和低制造成本的优势&#xff0c;但是在与现实中的物体进行频繁接触时易受磨损。而触觉仿真器可大幅降低硬件成本&#xff0c;同时为后续技能学习任务提供仿真训练环境。为此&#xff0c;来自东南大学自动化学院的钱堃副教授研究团队和伦敦…

大厂常见算法50题-两数相加

专栏持续更新50道算法题&#xff0c;都是大厂高频算法题&#xff0c;建议关注, 一起巧‘背’算法! 文章目录 题目解法总结 题目 解法 定义一个节点pre&#xff0c;用于初始化结果链表的头部&#xff0c;cur指向pre&#xff0c;它将在遍历过程中用于构建新的链表。初始化进位变…

基于单片机的直流电机测速装置研究与设计

摘要: 基于单片机的直流电机测速装置采用了对直流电机的中枢供电回路串联取样电阻的方式实现对电机转速的精确实时测量。系统由滤波电路、信号放大电路、单片机控制电路以及稳压电源等功能模块电路构成。工作过程中高频磁环作为载体&#xff0c;利用电磁感应的基本原理对直流电…