Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic filter function
#1
This has been sitting in the back of my head for a while so I decided to make it. It will "clean" a file by replacing the dictionary's keys with it's values. It can be used on text files, and html files, whatever. Not really practical I just thought of it when I first started programming and didn't know how to do, but now I do Smile.
Code:
def clean(name):
        #add any curses you like, the keys represent curses, their values represent them filtered
        curses = {'crap' : 'crap', 'bitch' : 'female dog', 'fudge' : 'fudge'}

        string = ''

        file = open(name)
        reader = file.readlines()
        for x in reader:
                string = string.join(x)
        file.close
        for x in curses.keys():
                if x in string:
                        string = string.replace(x, curses[x])

        file = open(name, 'w')
        file.write(string)
        file.close
        print 'The file hase been successfully filtered'
        

if __name__ == '__main__':
        name = str(raw_input('What is the name of the file you want filtered?:'))
        clean(name)
Blackhat
[Image: izsyo6.jpg]


Reply


Messages In This Thread
Basic filter function - by uber1337 - 03-05-2010, 08:34 PM
RE: Basic filter function - by xerotic - 08-13-2010, 10:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  isprime function nevets04 5 2,131 05-05-2010, 05:30 PM
Last Post: wat

Forum Jump:


Users browsing this thread: 1 Guest(s)