Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法将从 SQL 查询返回的所有 NoneType 对象转换为空字符串?现在我正在做
curs.execute(query) for foo, bar, baz in curs.fetchall(): foo = foo or '' bar = bar or '' baz = baz or ''
但我确信有更好的方法。
谢谢
像这样的东西
new_list = [ ('' if x is None else x) for x in curs.fetchall() ]