Contact: aviboots(AT)netvision.net.il
39,884 questions
51,810 answers
573 users
file = open("d:\data.txt", "r") words = set(file.read().split()) print(words) ''' run: {'Profession:', 'Name:', 'Age:', 'Ajax', 'Programmer', '27'} '''
file = open("d:\data.txt", "r") words = set(file.read().split()) for w in words: print(w) ''' run: Name: Profession: Ajax Programmer Age: 27 '''
import re file = open("d:\data.txt", "r") words = set(file.read().split()) for w in words: print(re.sub(r'[^\w\s]', '', w)) # remove punctuation ''' run: Age 27 Ajax Programmer Profession Name '''