peewee 对象clone函数

Posted woshiaotian

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了peewee 对象clone函数相关的知识,希望对你有一定的参考价值。

起因:
我需要得到peewee对象的clone对象,写个简单的小程序

def clone(instance):
    obj = instance.__class__()
    # print a._meta.fields
    data = getattr(instance, "_data")
    for key in a._meta.fields:
    # print key
        if key != 'id':
            setattr(obj, key, data[key])
    return obj

以上是关于peewee 对象clone函数的主要内容,如果未能解决你的问题,请参考以下文章