_

django: TypeError: not enough arguments for format string

 

时间:2019-10-15 来源:人云亦云


 

django支持原生mysql语句,但是语句中有 % 符号时,会报错TypeError: not enough arguments for format string

直接把 % 改成 %% 可解决。如下:


错误写法:

bookObj = books.objects.raw(''' select * from books where name like "%python%" ''')

正确写法:

bookObj = books.objects.raw(''' select * from books where name like "%%python%%" ''')

赞助打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开微信扫一扫,即可进行扫码打赏哦

您的支持,鼓励我们做得更好!

「人云亦云」


标签: 涨知识 | 如有转载,请注明出处 |
本文链接:
http://blog.hellotom.top/articles/945/


亲,看完记得留下足迹哦


更多有料好玩的内容 尽在人云亦云公众号
360网站安全检测平台