python中变量和字符串的连接
字符串中加含变量,一定要内外包围相同。
如下输出:
table='abc'
str1='select * from '+table+''
str2="select * from "+table+""
str3='select * from "'+table+'"'
str4="select * from '"+table+"'"
print 'str1 is :',str1
print 'str2 is :',str2
print 'str3 is :',str3
print 'str4 is :',str4
输出结果:
str1 is : select * from abc
str2 is : select * from abc
str3 is : select * from "abc"
str4 is : select * from 'abc'