Python:如何根据输入中输入的日期激活某个列表。 [英] Python: how do I activate a certain list based on what date is entered in the input.

查看:75
本文介绍了Python:如何根据输入中输入的日期激活某个列表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始:对不起,我是这个网站和Python的新手!



我想编写一个可以使用的程序你想去动物园吗?

启动程序时,它应该询问您何时想要访问,然后输入日期。它还会问你什么时候你认为你会在那里,然后它会提供有关哪些特定动物在日期和时间醒来以及它们是否被喂食的信息。



这些动物应该可以在不同的季节使用,例如熊在冬天睡觉等等。所以我需要有名单覆盖整年〜365天。



我需要帮助才能开始使用,我可以使用哪些方法/功能来调用在给定日期和时间醒来的动物列表?

谢谢提前预订!

Jasmine



我尝试过的事情:



我用Google搜索并在日期方法上查看youtube并发现最适合使用的是datetime

Just wanna start with: I'm sorry, I'm new to this website and Python!

I want to code a program that can be used if you wanna visit a Zoo.
When you start the program it should ask you when you want to visit, and then you enter a date. It´ll also ask you what time you think youre gonna be there and then it'll provide information about what particular animals that are awake that date and time and also if they're being fed.

The animals are supposed to be available at different seasons, for examples the Bears are asleep during the winter etc. So I need to have lists that cover the enitre year ~ 365 days.

I need help with getting started, what methods/functions could I use to call the list of animals that are awake at a the given date and time?
Thank you in advance!
Jasmine

What I have tried:

I have googled and looked on youtube on date methods and found that the most suitable one to use would be datetime

推荐答案

DateTime肯定会一个好主意。但首先你需要为动物创建一些类。每个班级都会包含动物的详细信息,例如他们清醒时的日期等。我建议您通过 Python进行操作教程 - Python 3.4.7文档 [ ^ ]了解更多想法。
DateTime would certainly be a good idea. But first you need to create some classes for the animals. Each class will contain details of the animal, such as the dates when they are awake etc. I would suggest working through The Python Tutorial — Python 3.4.7 documentation[^] for further ideas.


这篇关于Python:如何根据输入中输入的日期激活某个列表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆