【发布时间】:2013-07-12 05:35:40
【问题描述】:
这里是 Python 新手...我想从 for 循环创建一个新元组。元组将在IN 子句中的 MySQL 选择查询中使用。它工作不正确,告诉我cur.execute 行有以下问题。
TypeError: not all arguments converted during string formatting
check_tz = []
for tz in pytz.common_timezones:
if now_utc.astimezone(timezone(tz)).strftime('%H') == '01':
check_tz.append(tz)
print check_tz
# Prints out something as follows. I cut the output short for the sake of this example.
# ['America/Anguilla', 'America/Antigua', 'US/Eastern']
cur.execute("SELECT * FROM users where timezone IN (%s)", check_tz)
for row in cur.fetchall():
print row[0]
【问题讨论】:
-
是的。完美运行!
标签: python