我正在使用Python编写一个调用JQL脚本的脚本。我该怎么做?
curl -D- -u fred:fred -X GET -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/search?jql=assignee=fred+order+by+duedate
假设以上是JQL查询。
这是我到目前为止所得到的“语法无效”错误。
from grt import executeScript
querystring = "curl -D- -u fred:fred -X GET -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/search?jql=project=QA+order+by+duedate&fields=id,key"
executeScript(querystring)
这是我的错误:
File "/home/.spyder2/temp.py", line 19
querystring = "curl -D- -u fred:fred -X GET -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/search?jql=project=QA+order+by+duedate&fields=id,key"
^
SyntaxError: invalid syntax
答案 0 :(得分:1)
您没有正确打开/关闭字符串:
querystring = "curl -D- -u fred:fred -X GET -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/search?jql=project=QA+order+by+duedate&fields=id,key"
应该是:
querystring = """curl -D- -u fred:fred -X GET -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/search?jql=project=QA+order+by+duedate&fields=id,key"""
因为字符串本身包含双引号。