Python “ValueError: incomplete format” print(“a%” % ”)
解决python打印%号和%format输出问题
>>> print('%s' %'1') 1 >>> print('%s%' %'1') Traceback (most recent call last): File "<pyshell#4>", line 1, in <module> print('%s%' %'1') ValueError: incomplete format
解决:用%%代替%
>>> print('%%[%s,%.2f]%%' %('1',0.986)) %[1,0.99]%
sql使用:
sql = ''' SELECT t. * FROM a t WHERE a.id=:id and data_time = '%s' and file like 'ss_%s_%%[%s]%%' ''' %('20190101','abc','z.txt')