Inspired by some C and C++ threads regarding finding a specific pattern in a file.
Pattern in a file
def find():
a = raw_input("Insert file: ")
b = raw_input("Insert pattern: ")
try:
found = 0
for i in open(a, 'r'):
if b in i:
found = 1
if found == 1: print "Patter was found."
else: print "Pattern not found."
except:
print "Invalid file."
find()
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
snippsat 661 Master Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
Lucaci Andrew 140 Za s|n
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.