Python Forum
Can you put encoded strings into .txt files?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can you put encoded strings into .txt files?
#1
Question 
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand strings and lists of strings Konstantin23 2 777 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,780 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  Search multiple CSV files for a string or strings cubangt 7 8,065 Feb-23-2022, 12:53 AM
Last Post: Pedroski55
  filecmp is not working for UTF-8 BOM encoded files sureshnagarajan 3 2,619 Feb-10-2021, 11:17 AM
Last Post: sureshnagarajan
  get original code after being encoded to UTF-8 ashok 18 5,929 Sep-08-2020, 04:17 AM
Last Post: ndc85430
  Trouble with encoded data (I think) fishglue 0 1,806 Oct-10-2019, 08:15 PM
Last Post: fishglue
  Finding multiple strings between the two same strings Slither 1 2,530 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  Extract Strings From Text File - Out Put Results to Individual Files dj99 8 4,958 Jun-28-2018, 10:41 AM
Last Post: dj99
  lists, strings, and byte strings Skaperen 2 4,242 Mar-02-2018, 02:12 AM
Last Post: Skaperen
  convert hex encoded string to ASCII Skaperen 4 114,386 Oct-02-2016, 09:22 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020