我的数据库中有 2 列被调用description,url 我想选择这两列,但只description向用户显示。问题是,当我遍历 fetchall 命令时,它要么选择这两个字符,要么只选择单个字符。这是我的代码:connection = pymysql.connect(user='fake', passwd='fake', host='db', port=1111, db='fake_db_name')searchResult = []try: with connection.cursor() as cursor: pushpin_sql = "SELECT description, url FROM pushpin WHERE pushpin.description LIKE '%" + str(searchTerm) + "%'" result = cursor.fetchall() for col in result: searchResult+=col connection.commit()finally: connection.close 输出是这样的:这是一只可爱的狗http://jiangzhenling.com/img/CS6400/dog/dog1.png如果我将其更改为: for col1,col2 in result: searchResult+=col1然后它只连接单个字符输出是这样的:吨H一世..等等。我怎样才能让它只连接我的描述而不是我的网址?
添加回答
举报
0/150
提交
取消