def test(login,password):
data="""<?xml version="1.0"?>
<soap-env>
<soap-env:Body>
<Auth>
<Login>login</Login><password>password</password>
</Auth>
<Ping>
</Ping>
</soap-env:Body>
</soap-env:Envelope>"""
return data
i can't add login and password when i use ' login ' and i can't do format string like this " "
CodePudding user response:
Try the below ('f' string)
def test(login,password):
data=f"""<?xml version="1.0"?>
<soap-env>
<soap-env:Body>
<Auth>
<Login>{login}</Login><password>{password}</password>
</Auth>
<Ping>
</Ping>
</soap-env:Body>
</soap-env:Envelope>"""
return data
print(test('jack','secret'))
output
<?xml version="1.0"?>
<soap-env>
<soap-env:Body>
<Auth>
<Login>jack</Login><password>secret</password>
</Auth>
<Ping>
</Ping>
</soap-env:Body>
</soap-env:Envelope>