world = "World"print "Hello " + world + " ! "
2. 使用占位符来内插
world = "World"print "Hello %s !" % world
3. 使用函数
li = ['my','name','is','bob']mystr = ' '.join(li)print mystr
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')
很简单
只要把
Xpath.replace(Xpath[35:36], num1)改成
Xpath.replace(Xpath[35:36], str(num1))以下是replace方法的详细说明
replace(...)S.replace(old, new[, count]) -> string
Return a copy of string S with all occurrences of substring
old replaced by new. If the optional argument count is
given, only the first count occurrences are replaced.
参数只能是str类型
1. 使用连接符: +
world = "World"print "Hello " + world + " ! "
2. 使用占位符来内插
world = "World"print "Hello %s !" % world
3. 使用函数
li = ['my','name','is','bob']mystr = ' '.join(li)
print mystr
上面的语句中字符串是作为参数传入的,可以直接用变量替换:
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')