python - python SQL查询:一元+的错误操作数类型:'str'
问题描述
我在python中遇到过这种类型的问题几次。我只想创建一个 sql 更新查询。
我的脚本如下
update1 = '''UPDATE User_Answer_Knowledge SET'''
+ "integration =" + str(21) + ", scope =" + str(12) + ", schedule =" + str(13) + ", cost =" + str(14)
+ ", quality =" + str(15) + ", resource =" + str(16) + ", communication =" + str(17) + "WHERE User_Key = 1"
那么究竟是什么问题呢?我也尝试了以下代码,但出现了同样的问题
update1 = '''UPDATE User_Answer_Knowledge SET'''
+ "integration =" + 21 + ", scope =" + 12 + ", schedule =" + 13 + ", cost =" + 14
+ ", quality =" + 15 + ", resource =" + 16 + ", communication =" + 17 + "WHERE User_Key = 1"
update1 = '''UPDATE User_Answer_Knowledge SET'''
+ "integration =" + "21" + ", scope =" + "12" + ", schedule =" + "13" + ", cost =" + "14"
+ ", quality =" + "15" + ", resource =" + "16" + ", communication =" + "17" + "WHERE User_Key = 1"
update1 = '''UPDATE User_Answer_Knowledge SET'''
+ "integration =" + '21' + ", scope =" + '12' + ", schedule =" + '13' + ", cost =" + '14' \+ ", quality =" + '15' + ", resource =" + '16' + ", communication =" + '17' + "WHERE User_Key = 1"
解决方案
你需要一些\
在行尾:
update1 = '''UPDATE User_Answer_Knowledge SET''' \
+ "integration =" + str(21) + ", scope =" + str(12) + ", schedule =" + str(13) + ", cost =" + str(14) \
+ ", quality =" + str(15) + ", resource =" + str(16) + ", communication =" + str(17) + "WHERE User_Key = 1"
否则字符串声明以新行结束
推荐阅读
- node.js - 在 Google App Engine 处理 /_ah/start 路由 NodeJ
- javascript - Asp.net RadiobuttonList onselectedindexchanged 确认
- java - 在 Akka 中使用 SLF4J
- python - 如何确定一个类是否由另一个类中的方法实例化?
- c# - UI上的Unity3D粒子系统不会在构建中显示
- c++ - 如何使用 if else 和函数在 C++ 中制作计算器?
- javascript - 如何使用 javascript、php 在 mxgraph 中的工作流编辑器中使用 xml 数据绘制图形
- javascript - 如何以最佳方式验证 joi 子模式
- r - 按值解构向量
- wordpress - 古腾堡区块验证失败(不期待孩子)