python execute()函数

cursor = cur.cursor()
s = ['goods']
res = cursor.execute("select * from %s where name='三星';", args=s)
print(cursor.fetchall())

报错,每次s传进去,good就变 'good',请问怎么处理

pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''goods' where name='三星'' at line 1")

 

试下这样做,如果是你预期的结果,可以了解下python的格式化字符串 

cursor = cur.cursor()
s = ['goods']
res = cursor.execute("select * from %s where name='三星';"% s[0])
print(cursor.fetchall())