我需要在sqlite3 create
语句中连接字符串变量。我只发现.format
对附加表名很有帮助。但是,我想将由其余create语句组成的整个字符串str
附加到该语句本身。任何帮助将不胜感激。
for x in range(0, 100):
if x == 99:
str += "port_%d integer not null" % (x)
else:
str += "port_%d integer not null, " % (x)
s_table = """ CREATE TABLE recordings(timestamp datetime default current_timestamp,
dev_name text not null,"""+str+"""); """ //how can I attach str in here?
c.execute(s_table)