f=open("foo.txt")
for line in f:
print (line)
f = open("data.txt","r")   #设置文件对象
st= f.read() #将txt文件的所有内容读入到字符串str中
f.close() #将文件关闭