我用python从mysql得到了一个错误的数据类型

2024-09-22 16:37:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我用phthon写了一个从mysql获取数据的程序

 query = ("select distinct packet  from http_sum where downloadspot = 'dilian'")
    cursor.execute(query)
    for (packet) in cursor:
       cdndata_name.append(packet)

如你所见,这是如此很简单,但是我得到了这样的数据:(u'panzarcn.rar公司',) 如何转换成字符串,谢谢


Tags: from程序httpexecutepacketmysqlwherequery
1条回答
网友
1楼 · 发布于 2024-09-22 16:37:06

这不是一个错误的数据类型,它是unicode,您应该使用它来处理代码中的文本。如果您真的需要将其转换为str,请查看the question linked by @Lafexlos中的答案。你知道吗

相关问题 更多 >