`
l120974020
  • 浏览: 58449 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

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()

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics