%d format: a number is required, not str。
python代码:
attr_sql = "INSERT INTO `ym_attribute` (`attr_name`, `type_id`, `attr_value`, `attr_show`, `attr_sort`) VALUES(%s, %s, %s, %s, %s)"
param = (product_attr, type_id, product_attr_v, ‘1‘, ‘1‘)
n = cursor.execute(attr_sql, param)
python执行上面的语句会报下面的错误:%d format: a number is required, not str。
最终在stackoverflow查到了问题的解决方案
http://stackoverflow.com/questions/5785154/python-mysqldb-issues
答案为:The format string is not really a normal Python format string. You must always use %s for all fields. 也就是MySQLdb的字符串格式化不是标准的python的字符串格式化,应当一直使用%s用于字符串格式化
python中MySQL模块TypeError: %d format: a number is required, not str异常解决
The format string is not really a normal Python format string. You must always use %s for all fields.
%d format: a number is required, not str。的更多相关文章
- python中MySQL模块TypeError: %d format: a number is required, not str异常解决
转载自:http://www.codeif.com/topic/896 python代码: attr_sql = "INSERT INTO `ym_attribute` (`attr_nam ...
- 解决python查询报%d format: a number is required, not str问题
文章链接:https://blog.csdn.net/u011878172/article/details/72599120 [问题描述] 1.在一条查询语句中,查询条件既包含了整形又包含了字符串型, ...
- pymysql连接提示format: a number is required, not str
最近想随手写一个简单的员工管理系统,第一次使用python连接数据库,在这个过程中就遇到了一些问题,遂记录 遇到问题习惯性百度一下,很多教程都不适合新手,有些还不知道是不是瞎写的,所以我觉得有必要自己 ...
- python问题:TypeError: a bytes-like object is required, not 'str'
源程序: import socket target_host = "www.baidu.com" # 127.0.0.1 target_port = 80 # 建立一个socket ...
- python3 TypeError: a bytes-like object is required, not 'str'
在学习<Python web开发学习实录>时, 例11-1: # !/usr/bin/env python # coding=utf-8 import socket sock = sock ...
- 【爬坑】Python 3.6 在 Socket 编程时出现类型错误 TypeError: a bytes-like object is required, not 'str'
1. 问题描述 Python 3.6 在 Socket 编程时出现错误如下 Traceback (most recent call last): File "F:/share/IdeaPro ...
- TCP客户端和服务器间传输数据遇到的TypeError: a bytes-like object is required, not 'str'问题
使用python实现python核心编程3第472页和474页的TCP时间戳服务器和客户端服务器间数据传输编程时遇到TypeError: a bytes-like object is required ...
- linux下运行python3出现TypeError: a bytes-like object is required, not 'str'
目标:用python将中文存入csv,且中文正常显示. 环境:linux,python3 百度N久,方法都不行或是比较复杂. 以上代码用python3运行后,出现TypeError: a bytes- ...
- sbt package报错:a bytes-like object is required, not 'str'
Traceback (most recent call last): File , in <module> s.sendall(content) TypeError: a bytes-li ...
随机推荐
- kvm动态修改内存和cpu
https://www.cnblogs.com/nmap/p/6369180.html
- vue.js使用echarts一分钟简单入门
图表的使用在企业级软件中使用越来越普遍,前端开发人员可以使用常用的echarts开源库来进行图表展示的开发,公司最近提出需要丰富系统首页的内容,趁此机会分享一下如何在使用vue.js框架下使用echa ...
- PAT甲级——A1155 HeapPaths【30】
In computer science, a heap is a specialized tree-based data structure that satisfies the heap prope ...
- 图推荐-基于随机游走的personrank算法
转自http://blog.csdn.net/sinat_33741547/article/details/53002524 一 基本概念 基于图的模型是推荐系统中相当重要的一种方法,以下内容的基本思 ...
- 基于虚拟用户登录的ftp服务配置
文章结构: 一.使用逻辑卷配置ftp数据存放目录 二.安装和配置vsftpd服务 三.使用不通权限的用户访问ftp服务器 系统环 ...
- python面试如何以相反顺序展示一个文件的内容?
>>> for line in reversed(list(open('Today.txt'))): print(line.rstrip())containeritertools D ...
- JQ的live学习
$("#StartTime").live("blur keypress keyup",function(){ if($("#EndTime" ...
- python3学习笔记——数字、字符串、列表、字典、元组
什么是python解释器? python代码在解释器中运行.解释器是代码与计算机硬件之间的软件逻辑层. python的执行过程 ...
- 个人公众号服务端开发Demo
公众号出来很久了,也可以个人申请.知道公众号的服务端开发其实很简单,接口调用封装,数据存取,不外如是. 人一旦懒了,真的是 “无可救药” 了...现简单描述晚到的公众号HelloWorld 思路 公众 ...
- 笔试算法题及解答(Python)
1.给定任意一个正整数,求比这个数大且最小的“不重复数”,“不重复数”的含义是相邻两位不相同,例如1101是重复数,而1201是不重复数 # coding:utf-8 ''' Created on 2 ...