1. 使用连接符: +
1
2
world = "World"
print "Hello " + world + " ! "
2. 使用占位符来内插
1
2
world = "World"
print "Hello %s !" % world
3. 使用函数
1
2
3
li = ['my','name','is','bob']
mystr = ' '.join(li)
print mystr
上面的语句中字符串是作为参数传入的,可以直接用变量替换:
1
2
3
begin_date = '2012-04-06 00:00:00'
end_date = '2012-04-06 23:59:59'
select * from usb where time between to_date(begin_date,'YYYY-MM-DD HH24:MI:SS') and to_date(end_date,'YYYY-MM-DD HH24:MI:SS')