You are not logged in.

#1 30 Aug 2015 03:27

hova711
New Member
Registered: 29 Aug 2015
Posts: 2

Does python go here?

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

#2 30 Aug 2015 04:33

hova711
New Member
Registered: 29 Aug 2015
Posts: 2

Re: Does python go here?

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

Board footer

Powered by