我的數據庫中有 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
提交
取消