这是老师编的一段程序,为你展示的十二星座的信息。你能够试着实现一下吗?
时间: 2023-05-25 13:04:28 浏览: 207
抱歉,作为一名语言模型,我无法进行具体的编程操作。但是,我可以提供一个可能的参考实现供您参考:
```python
# 定义存储不同星座信息的字典
star_signs = {
"水瓶座": {"date": "01-20~02-18", "element": "风", "characteristics": "聪明、好奇、独立"},
"双鱼座": {"date": "02-19~03-20", "element": "水", "characteristics": "敏感、有创意、富有同情心"},
"白羊座": {"date": "03-21~04-19", "element": "火", "characteristics": "积极、果断、勇敢"},
"金牛座": {"date": "04-20~05-20", "element": "土", "characteristics": "实际、踏实、稳重"},
"双子座": {"date": "05-21~06-21", "element": "风", "characteristics": "机智、好奇、富有表现力"},
"巨蟹座": {"date": "06-22~07-22", "element": "水", "characteristics": "敏感、善良、家庭意识强"},
"狮子座": {"date": "07-23~08-22", "element": "火", "characteristics": "自信、乐观、慷慨大方"},
"处女座": {"date": "08-23~09-22", "element": "土", "characteristics": "谨慎、完美主义、善于分析"},
"天秤座": {"date": "09-23~10-23", "element": "风", "characteristics": "公正、平衡、重视友情"},
"天蝎座": {"date": "10-24~11-22", "element": "水", "characteristics": "神秘、坚定、富有洞察力"},
"射手座": {"date": "11-23~12-21", "element": "火", "characteristics": "乐观、自由、追求新鲜感"},
"摩羯座": {"date": "12-22~01-19", "element": "土", "characteristics": "踏实、务实、善于计划"}
}
# 获取用户输入的星座名字
star_sign = input("请输入您想查询的星座名字:")
# 判断字典中是否存在该星座信息,并进行输出
if star_sign in star_signs:
sign_info = star_signs[star_sign]
print("星座:", star_sign)
print("日期范围:", sign_info["date"])
print("元素属性:", sign_info["element"])
print("特点描述:", sign_info["characteristics"])
else:
print("抱歉,没有查询到您输入的星座信息。")
```
这段程序首先定义了一个名为`star_signs`的字典,用于存储不同星座的信息;然后获取用户输入的星座名字,并通过判断是否存在该星座信息,来进行相应的输出。在输出星座信息时,可以通过字典的键值对来获取相应的属性值。
阅读全文