#10.1.6
filename='pi_million_digits.txt'
with open(filename) as file_object:
lines=file_object.readlines()#返回的是以行为单位的列表
pi_string=''#用于储存字符串的变量
for line in lines:
pi_string+=line.strip()
print(pi_string[:52]+"...")
print(len(pi_string))
print(type(lines))#列表
print(type(pi_string))#str
#变式
a='pi_million_digits.txt'
with open(a) as b:
c=b.readlines()
d=''
for i in c:
d+=i.strip()
print(d[:52]+'...')
print(len(d))
10.1.7圆周率中包含你的生日吗
filename='pi_million_digits.txt'
with open(filename) as file_object:
contents=file_object.readlines()
a=''
for i in contents:
a+=i.strip()
print(a[:52]+"...")
print(len(a))
phone=input("what is your phone number:")
if phone in a:
print("your phone number appears in the first million digits of pi.")
else:
print("your phone number does not appears in the forst million digits of pi.")