我得到的是:
from sqlalchemy import *
from sqlalchemy.orm import *
from web.models.card import *
connectionString = "postgresql://www:www@localhost/prod"
databaseEngine = create_engine(connectionString)
sessionFactory = sessionmaker(autoflush = True, autocommit = False, bind = databaseEngine)
session = sessionFactory()
CardsCollection = session.query(card).all()
_content = {}
for index in range(0, len(CardsCollection)):
c = CardsCollection[index]
_content[index] = c
print json.dumps(_content)
错误就在这里:
^{pr2}$有人能帮我解决这个问题吗?我尝试了一些方法,研究了字典的工作原理。。。但它不是冲着我跳出来的。在
很明显,在卡片模型上重写self.__dict__(self)
方法就是这样做的。不过,我不太清楚原因。在
__dict__
是一个保持实例当前状态的special attribute,用方法重写它肯定会导致麻烦。在相关问题 更多 >
编程相关推荐