Python发布多个标题

2024-09-28 03:22:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着用python发布一些xml以编程方式创建一个论坛主题。基本上,我需要用以下标题发布xml:

授权:基本 内容类型:application/atom+xml

这是我试图使用的代码,但它需要在单个请求中同时使用两个头。post():

import base64
from requests.auth import HTTPBasicAuth
import requests

xml = "<xml code here>"
url = 'https://server/forums/atom/forum?id=b7915594-5c46-4ae6-916a-be869aabb327'
userID = 'userid'
password = 'password'

header = {"Content-type": "application/atom+xml"}

r = requests.post(url, headers=header, auth=HTTPBasicAuth(userID,password), data=xml)

任何帮助都非常感谢。 提前谢谢你


Tags: importauthurlapplication编程方式passwordxml

热门问题