输入控制和编码转换还没写,呜呜
题目要求:
将以下数据存储到const.csv文件中
星座,开始月日,结束月日,Unicode
水瓶座,120,218,9810
双鱼座,219,320,9811
白羊座,321,419,9800
金牛座,420,520,9801
双子座,521,621,9802
巨蟹座,622,722,9803
狮子座,723,822,9804
处女座,823,922,9805
天秤座,923,1023,9806
天蝎座,1024,1122,9807
射手座,1123,1221,9808
摩羯座,1222,119,9809
请编写程序,读入CSV文件中数据,循环获得用户输入,直至用户直接输入“Q”退出。根据用户输入的星座名称,输出此星座的出生日期范围及对应字符形式。如果输入的名称有误,请输出“输入星座名称有误!
ls=[
["星座","开始月日","结束月日","Unicode"],
['水瓶座','120','218','9810'],
['双鱼座','219','320','9811'],
["白羊座",'321','419','9800'],
['金牛座','420','520','9801'],
['双子座','521','621','9802'],
['巨蟹座','622','722','9803'],
['狮子座','723','822','9804'],
['处女座','823','922','9805'],
['天秤座','923','1023','9806'],
['天蝎座','1024','1122','9807'],
['射手座','1123','1221','9808'],
['摩羯座','1222','119','9809']
]
f=open("const.csv","w")
for row in ls:
f.write(",".join(row)+"\n")
f.close()
f=open("const.csv","r")
ls1=[]#csv文件的存储
for line in f:
ls1.append(line.strip("\n").split(","))
f.close()
#print(ls1)
'''for i in ls1:
line=""
for item in i:
line+="{:10}\t".format(item)
print(line)'''
list1=[]
while True:
xingzuo=input("")
if xingzuo=="Q":
break
else:
print("你输入的是"+xingzuo.title())
list1.append(xingzuo.title())
#print(list1)
for i in list1:
for m in ls1:#行
for n in m:#列
if i==n:
#print(m)
print("{}的开始日期是{},结束日期是{},符号是{:}".format(m[0],m[1],m[2],m[3]))