python 中写mysql 关于 like % 问题

#@ 1 - 正常执行的mysql 语句为:
 select * from RESIDENTIAL_AREA where RA_ID like  'HF-%' 

#@ 2 - 在python 代码中为: 最后面的那个 %  需要4个% 去代替(raid = HF-)
select_sql = ''' select * from RESIDENTIAL_AREA where RA_ID 
   like  '%s%%%%' ''' % (raid)



#@ 3 - python 代码中 输出结果为:print(select_sql)
 select * from RESIDENTIAL_AREA where RA_ID like  'HF-%%' 

 

你可能感兴趣的:(python)