|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
程序:
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()
birthday = input("Enter your birthday, in the form mmddyy: ")
if birthday in pi_string:
print("Your birthday appears in the first million digits of pi!")
else:
print("Your birthday does not appear in the first million digits of pi.")
报错:
Enter your birthday, in the form mmddyy: 981030
Traceback (most recent call last):
File "pi_string.py", line 11, in <module>
if birthday in pi_string:
TypeError: 'in <string>' requires string as left operand, not int
|
|