python simple function

1. Read a file and print contect

import os
outdirs = os.popen("cat outdirs.list").read() print "% s" % outdirs

 

2. Read a file and print line by line

f = open("outdirs.list","r")
for x in f:
        print(x)
f.close()

  

posted on 2019-05-20 16:11  guolongnv  阅读(59)  评论(0)    收藏  举报