python - 如何在python中将变量插入mysql

标签 python mysql jira-rest-api

我在所有可能的组合中使用了 .format 和 %s 命令,但没有任何进展。 当我这样使用它时它工作正常:

last_issue = jira.search_issues('assignee = "ahmet" order by created desc')[0]

但是我需要受让人成为一个变量,如果我以这种方式使用它或类似的东西:

assignee = "ahmet"
last_issue = jira.search_issues('assignee =', assignee, 'order by created desc')[0]

它给出了类似的错误

response headers = {'Vary': 'User-Agent', 'X-AREQUESTID': '578x1623860x1', 'X-ASESSIONID': 'x0ubjs', 'X-ASEN': 'SEN-L0000000', 'Cache-Control': 'no-cache, no-store, no-transform', 'X-Content-Type-Options': 'nosniff', 'X-AUSERNAME': 'ekaterina', 'X-Seraph-LoginReason': 'OK', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'Date': 'Mon, 11 Sep 2017 09:38:10 GMT', 'Content-Type': 'text/html;charset=UTF-8', 'Server': 'nginx/1.13.0', 'Connection': 'keep-alive'}
    response text = 

我应该如何以适当的方式创建变量?

最佳答案

它有效!

 var = "assignee = '{}' order by created desc".format(assignee)
 last_issue = jira.search_issues(var)[0] 

关于python - 如何在python中将变量插入mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46152550/

相关文章:

python - 如何在 python 3.5 中 pip 安装模式包?

mysql - 如何在 INSERT 之前检查 mysql 中的值

MySQL - 选择当时的情况

python-3.x - Python - Jira 使用/rest/api/2 创建具有共享配置的项目(现有项目)

java - 项目中未认可的JRJC

jira-rest-api - 在远程 API 中访问 Jira 公告横幅

python - boolean 语句在应该为 false 时返回 true(使用 and & or)

python - 屏蔽数组 : How to change symbol representing masked values

python - 'can' t 分配给文字'意味着什么?

php - 如何使用 PHP 代码将日期从数据库表加载到 fullcalender? [没有 Ajax ]