I know I'm a newbie in programming but I'd like to write a Python script to censor some data.
My inputfile in structured like this:
username:password
username:p4ssw0rd
mail:pa3386
I need to censor all characters after the first 2-3 character right after the colon ":"
The results should be something like this:
username:pass****
username:p4ss**
mail:pa88***
Is there a way to do this?
I've been struggling a lot and tried with strip or split but i'm not able to get this to work...
f = open("myfile.txt",'r')
#result = [x.strip() for x in my_string.split(',')]
strings = f.read().strip()
print(strings)
targets = strings.split(':')
print(targets)
for x in range(len(strings)):
strings[x].strip()
print(strings)
lines = f.read().split('\n')
length = len(lines)
print(length)
for x in range(length):
print(strings[x])