以下是一个简单的Python程序,用于测试两个人的缘分指数。这个程序基于一个简化的缘分指数计算方法,即根据两个人的生日在一年中的位置来计算他们的缘分指数。
```python
import datetime
def get_birthday_month_day(birthdate):
year, month, day = birthdate.split("-")
return int(month), int(day)
def calculate_birthday_index(month, day):
days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if int(month) == 2 and int(day) == 29 and int(year) % 4 != 0:
return 29 # Leap year
else:
return days_in_month[int(month) - 1]
def calculate_bond_index(person1_birthdate, person2_birthdate):
index1 = calculate_birthday_index(*get_birthday_month_day(person1_birthdate))
index2 = calculate_birthday_index(*get_birthday_month_day(person2_birthdate))
return (index1 + index2) / 2
def main():
person1_birthdate = input("请输入第一个人出生日期(格式:YYYY-MM-DD):")
person2_birthdate = input("请输入第二个人出生日期(格式:YYYY-MM-DD):")
bond_index = calculate_bond_index(person1_birthdate, person2_birthdate)
print(f"两个人的缘分指数为:{bond_index:.2f}")
if __name__ == "__main__":
main()
```
### 使用说明:
1. 运行程序。
2. 输入两个人的出生日期,格式为 `YYYY-MM-DD`。
3. 程序将输出两个人的缘分指数。
### 注意事项:
- 这个程序使用了一个简化的缘分指数计算方法,实际应用中可能需要更复杂的算法。
- 出生日期的格式必须为 `YYYY-MM-DD`。
- 程序假设输入的日期是有效的,并且没有进行错误处理。