实现add watcher to JIRA issue api .
它接受一个字符串对象作为数据输入。
当使用 python 请求进行后调用时,我这样做:
数据=“\””+数据+“\””
req = requests.post(full_url, headers=headers, data=data)
是否有更好的方法将字符串参数传递给 post 调用,同时保留撇号?
最佳答案
更干净的方法是使用 str.format(...)
功能为:
# string within single quote
data = '"{}"'.format(data)
# OR, string as double quote but with escape character as
data = "\"{}\"".format(data)
关于python - 如何将带撇号的字符串对象传递给 POST 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43528170/