# filename:python3.1.py
# author:super
# date:2018-03-01
# with open(r'd: est est.txt') as file_object:
# content = file_object.read()
# print(content.rstrip())
#
# filename = r'd: est est.txt'
# with open(filename) as file:
# for i in file:
# print(i.rstrip())
# 用open方法就不用close()了 , open里面会自带的
# 用open的时候那会又不想用这个文件, 可以用file.readlines() 存储起来
# 再用for来把readlines()里面的内容读出来
filename = r'd: est est.txt'
with open(filename) as files:
lines = files.readlines()
pi_string = ''
# 在读取文件内容的时候,读出来的内容均为字符串, 如果要作为int来使用, 则要int()来转换
for line in lines:
pi_string += line.strip()
print(line.rstrip())
print(pi_string)