Python中文
首页
教程
问答
标签
搜索
登录
注册
python&MySQLdb TypeError('不是所有参数在字符串格式化过程中转换',)
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我一直在谷歌上搜索,没法解决我的问题。在</p> <p>在我的代码的早期部分,我有许多查询使用参数,但在我以前的例子中,我只传递字符串。我也知道我的查询是有效的,因为我已经在Sequel Pro中尝试过了。在</p> <p>然后就在这一段代码中结束了:</p> <pre><code> CA = 'CA10' Rank = 5 CreateTempTable2 = "CREATE TEMPORARY TABLE IF NOT EXISTS BadTranscripts AS " + \ "(SELECT DISTINCT Transcript FROM Exon_InDelCons X, Exons E2, EnsSequences G WHERE " + \ "CA = %s AND (Type = 'inserted' OR Type = 'deleted') AND Length > 11 " + \ "AND X.Transcript = E2.EnsTranscriptId AND E2.Rank < %s " + \ "AND X.Exon = E2.EnsExonId AND E2.EnsParentId = G.GenomicEnsId)" args2 = CA, Rank try: cursor.execute(CreateTempTable2, args2) cursor.connection.autocommit(True) except Exception, e: print "Can't create Temp Table BadTranscripts", repr(e) </code></pre> <p>CA是一个字符串,Rank是一个整数。在</p> <p>当我运行这段代码时,我得到一个错误:</p> ^{pr2}$ <p>如果有帮助的话,我可以在macosx10.9.5上运行python2.7和MySQL服务器 提前感谢您的帮助!在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>回答,因为我没有足够的声誉来评论。你能报告一下在你之前替换'%s'时发生了什么吗cursor.execute?在</p> <p>试着去做</p> <pre><code>CreateTempTable2 %(CA, Rank) </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
无法使用Django/mongoengine连接到MongoDB(身份验证失败)
2 回答
无法使用Django\u mssql\u后端迁移到外部hos
3 回答
无法使用Django&Python3.4连接到MySql
3 回答
无法使用Django+nginx上载媒体文件
7 回答
无法使用Django1.6导入名称模式
2 回答
无法使用Django1.7和mongodb登录管理站点
6 回答
无法使用Djangoadmin创建项目,进程使用了错误的路径,因为我事先安装了错误的Python
1 回答
无法使用Djangockedi验证CBV中的字段
6 回答
无法使用Djangocketditor上载图像(错误400)
10 回答
无法使用Djangocron进行函数调用
8 回答
无法使用Djangofiler djang上载文件
2 回答
无法使用Djangokronos
4 回答
无法使用Djangomssql provid
2 回答
无法使用Djangomssql连接到带有Django 1.11的MS SQL Server 2016
8 回答
无法使用Djangomssq迁移Django数据库
1 回答
无法使用Djangonox创建用户
6 回答
无法使用Djangopyodb从Django查询SQL Server
5 回答
无法使用Djangopython3ldap连接到ldap
7 回答
无法使用Djangoredis连接到redis
5 回答
无法使用Django中的FK创建新表
7 回答