星期1-7会输出后天是星期几 , 比如:输入1会输出3,输入7会输出2,用python写出来
时间: 2023-02-07 15:33:03 浏览: 117
要输出后天是星期几,可以使用如下 Python 代码:
```
def print_tomorrow(day_of_week):
# 将星期转换为数字,星期一对应数字1,星期二对应数字2,以此类推
day_of_week = int(day_of_week)
# 计算后天是星期几
tomorrow = (day_of_week + 2) % 7
# 将数字转换为星期
if tomorrow == 0:
print("后天是星期日")
elif tomorrow == 1:
print("后天是星期一")
elif tomorrow == 2:
print("后天是星期二")
elif tomorrow == 3:
print("后天是星期三")
elif tomorrow == 4:
print("后天是星期四")
elif tomorrow == 5:
print("后天是星期五")
elif tomorrow == 6:
print("后天是星期六")
# 测试
print_tomorrow(1) # 输出:后天是星期三
print_tomorrow(7) # 输出:后天是星期二
```
希望这能帮到你!