Search code examples
pythonpython-requestsoperation

Python Operation % not working?


I cant seem to get this working, cant someone point me in the right direction? If i put the the values without promting it works buut when i do this i get error.

username1 = raw_input('Enter Username:\n')
password = raw_input('Enter Password:\n')
r = requests.get("https://linktoasp.net/",auth=HttpNtlmAuth("domain\\%s",password),cookies=jar) % (username1)  

Error:

Traceback (most recent call last): File "attend_punch.py", line 32, in

r = requests.get("https://linktoasp.netserver/homeportal/default.aspx",auth=HttpNtlmAuth("domain\\%r",password),cookies=jar)

% (username1) TypeError: unsupported operand type(s) for %: 'Response' and 'str'


Solution

  • You could try this instead

    auth = HttpNtlmAuth("domain\\%s" % username1, password), cookies = jar)