当前位置:Gxlcms > 数据库问题 > python向mysql插入数据一直报TypeError: must be real number,not str

python向mysql插入数据一直报TypeError: must be real number,not str

时间:2021-07-01 10:21:17 帮助过:40人阅读

注意,Python向MySQL中写入数据时无论输入的数据类型如何,语句中的占位符均使用%s,例如

技术图片

 

 

 这里的price我是int类型的,所以占位符用的%d,后来改成float类型,占位符改为%f,都不可以!!!!

也就是无论输入的数据是否为字符串,占位符都是%s,不存在%f,%d这种概念。

技术图片

 

python向mysql插入数据一直报TypeError: must be real number,not str

标签:ima   字符串   type   python   就是   数据   mamicode   code   float   

人气教程排行