-2
我已经编写了一个python脚本,用于从表中获取特定数据并显示数据。以下是脚本:python输出不显示在命令提示符上,但脚本正常工作
import MySQLdb
import os,sys
path="C:/Python27/"
conn = MySQLdb.connect (host = "localhost",user = "root", passwd = "cimis",db = "cimis")
c = conn.cursor()
station=[2,80,7]
date="8/1/2016"
hour=[200,300,400]
message = """select stationId,Date,hour,airTemperature from cimishourly where stationId in %s and Date=%s and hour in %s"""
c.execute(message,(station,date,hour))
result=c.fetchall()
for row in result:
print(row)
conn.commit()
c.close()
当我创建站ID列表时,它可以很好地显示cmd上的所有输出。但是,当我添加小时列表时,脚本运行时没有错误,但在cmd上没有看到输出。 请帮我。谢谢
尝试从这里接受的答案:http://stackoverflow.com/questions/4574609/executing-select-where-in-using-mysqldb – nkhumphreys
谢谢。那正是我所期待的 –