I am trying to rename the extension of a text file to zip as advised here. The file is being written based on a base64 encoded response from a server, which I am decoding before writing.
This is my code snippet:
f = open("response.txt","wb")
f.write(json.loads(response.text)['Binary'].decode('base64'))
f.close()
file1 = "C:\Users\xyz\response.txt"
base = os.path.splitext(file1)[0]
os.rename(file1, base + ".zip")
I am getting the following error even though the file is in the absolute path specified in my code:
WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect
Please assist.