python文件读写2

读文件:

fname = raw_input("Please input the file path:")

print fname

 

try:

    fobj = open(fname,"r")

except IOError,e:

    print "The file '%s' is read error! \n"%fname,e

else:

    for eachLine in fobj:

        print eachLine,

    fobj.close()

你可能感兴趣的:(python)