def if_digit(num):
if num == "0":
return 0
elif num == "1":
return 1
elif num == "2":
return 2
elif num == "3":
return 3
elif num == "4":
return 4
elif num == "5":
return 5
elif num == "6":
return 6
elif num == "7":
return 7
elif num == "8":
return 8
elif num == "8":
return 8
elif num == "9":
return 9
# str_vis_text = input("Enter the first 13 digits of an ISBN-10 as a string: ")
# str_vis_text = "978013213079"
str_vis_text = "978013213080"
len_num = len(str_vis_text)
def run_text(num_t, text_about):
text_sum = 0
for i in range(0, num_t,2):
text_sum +=if_digit(text_about[i])+(3*if_digit(text_about[i + 1]))
# print(text_sum)
if 10-text_sum % 10 == 10:
return "0"
else:
return 10-text_sum % 10
a = str(run_text(len_num, str_vis_text))
print(str_vis_text+a)
图片上传失败.但是结果成功了.
大家自己尝试吧