我有python生成的输出
(u'PK_LampFactoryTest',)
(u'DF__Thermosta__Enabl__7B264821',)
(u'filestream_tombstone_2073058421',)
(u'RetentionSettings',)
(u'Alarms',)
(u'syscommittab',)
sqlquery ='从sys.objects中选择名称' cursor.execute(sqlquery)
#conn.commit()
for row in cursor:
print(row)
答案 0 :(得分:1)
u仅表示它是unicode。
for row in cursor:
print(row.encode('ascii', 'ignore'))
但是那不了解您的代码的整体情况,只会使该打印语句看起来不错(通过编码字符串)
答案 1 :(得分:0)
尝试一下:
import json, ast
for row in cursor:
print(ast.literal_eval(json.dumps(row)))