import pymysql conn = pymysql.connect( host='127.0.0.1', user='root', password='g53743001', db='erptest', charset='utf8' ) cur5 = conn.cursor() # 獲取欄位資料 t1 = '乾燥貨櫃' sql5 = "select DISTINCT 系統 from abc" sql5 += ' WHERE 產品 = \'' + t1 + '\' ' cur5.execute(sql5) print(sql5) labels5 = cur5.fetchall() labels5 = [g[0] for g in labels5] print(labels5) # 獲取欄位資料 t2 = '清洗槽組立' sql6 = "select DISTINCT 模組圖名 from abc" sql6 += ' WHERE 系統 = \'' + t2 + '\' ' cur5.execute(sql6) print(sql6) labels5 = cur5.fetchall() labels5 = [g[0] for g in labels5] print(labels5)