Can you put encoded strings into .txt files? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Can you put encoded strings into .txt files? (/thread-37128.html) |
Can you put encoded strings into .txt files? - Alivegamer - May-04-2022 I have been trying to encode a text and then put it into a txt file but it doesn't show correctly. When it's in the variable : b'\xff\xfe\x00\x00b\x00\x00\x00l\x00\x00\x00o\x00\x00\x00p\x00\x00\x00' when it's in the txt file : p a s s w o r d Is there a way to put in the variable's data into the txt? The python code: def Sighin(): os.system("cls") print("What is your name?") Input = input(": ") Input.lower() fileName = Input os.system("cls") print("What's your password?") Input = input(": ") fileContent = Input.encode("utf_32") print(fileContent) FileW = open(fileName + ".txt", "wb") FileW.write(fileContent) FileW.close() |