文件t

fo = open("SunSign.csv","r", encoding='utf-8')

ls = []for line in fo:

line = line.replace("\n","")

ls.append(line.split(","))

fo.close()

while True:

InputStr = input() # 请输入星座名称,例如双子座

InputStr.strip()

flag = False

if InputStr == 'Q':

break

for line in ls:

if InputStr == line[0]:

print("{}座的生日位于{}-{}之间。".format(chr(eval(line[3])),line[1],line[2]))

flag = True

if flag == False:

print("输入星座名称有误!")

你可能感兴趣的:(文件t)