|
- from loguru import logger
- import pickle
- from loguru import logger
- # 定义一个类
- # class Person:
- # def __init__(self, name, age):
- # self.name = name
- # self.age = age
- #
- # # 创建一个Person实例
- # person = Person("Alice", 25)
- #
- # # 使用Loguru的serialize方法将Person实例序列化为字节字符串
- # serialized_person = logger.serialize(person)
- # print(serialized_person)
- # # 使用pickle库将字节字符串反序列化为Python对象
- # deserialized_person = pickle.loads(serialized_person)
- #
- # # 输出反序列化后的对象属性
- # print(deserialized_person.name) # Alice
- # print(deserialized_person.age) # 25
- aa = {"name": "11111"}
- logger.info(aa)
|