How to remove from print nulls outputs (Python 3)

Question:

this is my first question about programing. I have problem with loading date from vmem file. Try to print all chars in long string like: fkvjdhde.
Now its look like:
my output from f print

My idea is create outputs with understand ascii symbols i[0:7] line after line. How to remove all chars what I don’t want (NULLs, space and more)? Thanks for help!

def remove(x):
    return x.replace('n', "")
    return x.replace('x00', "")
    return x.replace('x01', "")

    with codecs.open('file.vmem', 'r', encoding='utf-8', errors='ignore') as fdata:
    for i in fdata:
        
        letsClean = remove(i)
     
        counting = 1
        a = 0
        b = 8
        for i in letsClean:
            a += 1
            b += 1
            takie = letsClean[a:b]
            print(takie)
Asked By: kjurczyq

||

Answers:

Keep what you want to keep.

keep = ''.join(chr(c) for c in range(32,127))
def cleanup(x):
    return ''.join(k for k in x if k in keep)
Answered By: Tim Roberts
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.