我正在开发应该与数据库一起工作的python应用程序。我遇到了一个问题。在PHP我可以直接只需$符号变量的查询,但在python我写这段代码:蟒蛇PHP像字符串连接
query = "INSERT INTO shops (id, shop_id, shop_url, shop_name, shop_cat, datas)" + "VALUES("+count+", "+str(shop_id)+", "+shop_url+", "+shop_name+", "+shop_cat+", "+pdfs+datas+");"
是否有任何PHP做类似的方法,我的意思是做一个字符串里面?
你应该真的使用DB API和那些替代你的方法。以这种方式构建字符串是SQL注入攻击的沃土。 – Keith 2012-03-21 10:40:08
你在找什么被称为[字符串插值](http://stackoverflow.com/search?q=python+string+interpolation) – georg 2012-03-21 10:47:18