我试图读取变量中的服务器名称(例如:server1)并将其传递给 url。但是, url 不接受变量,而只接受硬编码的服务器名称。
我有什么办法可以做到这一点吗?
def connect_to_BNAserver(BNAserver):
connection = http.client.HTTPConnection(BNAserver)
baseurl="'https://"+BNAserver+"/rest/login'"
header = {"WSUsername": BNAUser, "WSPassword": BNAPass,"Accept": "application/vnd.brocade.networkadvisor+json;version=v1"}
connection.request('POST',BaseUrl,headers=header)
以下作品:
header = {"WSUsername": BNAUser, "WSPassword": BNAPass,"Accept": "application/vnd.brocade.networkadvisor+json;version=v1"}
connection.request('POST','https://server1/rest/login',headers=header)