You are not logged in.
Pages: 1
Hello All,
I'm learning python the ol trial and error method. I have come up with a script to print out lines from a text doc to another text doc. It doesn't select the lines when I input the file name, it just prints none for all the lines of text in my sample. Any help would be greatly appreciated.
#################################################################################3
#import re
import re
#select source file
a=open(raw_input("Enter full path of source file using using \\ instead of \: "), "r")
#select destination file
b=open(raw_input("Enter full path of destination file using \\ instead of \: "), "a")
a
b
#actual copy command
for line in a.readlines():
print re.match ('sysconfig' , '(failed)')
Offline
I've done a little more and I have two questions:
##########################
What I've come up with so far
##########################
#import re
import re
#select source file
a=open(raw_input("Enter full path of source file using using \\ instead of \: "), "r")
#select destination file
b=open(raw_input("Enter full path of destination file using \\ instead of \: "), "a")
a
b
#actual copy command
for line in a.readlines():
searchObj = re.search( r'sysconfig', line)
if searchObj:
print "search --> searchObj.group() : ", searchObj.group() <-- how do i print the whole line
else:
print "Nothing found!!" <-- Can I just put an end?
Offline
Pages: 1