Search code examples
pythonlinuxtxtextcontrol

Python based on .txt file


I own a txt file that contains many lines Each line will be as the next

email1:password1
email2:password2
...
...
...
emailxx:passwordxx

I want a python code that reads the file line at a time Where the next is printed

email=username1
pass=password1

email=username2
pass=password2

email=username3
pass=password3
...
...
...
email=usernamexx
pass=passwordxx

Solution

  • thanks i fixed it

    with open("xxx.txt") as f:
    for line  in f.readlines():
       #print(line)
       values = line.split(":")
       email = values[0]
       pasw = values[1]
       print(f"user={email}\npass={pasw}\n")