• <bdo id='jZm4e'></bdo><ul id='jZm4e'></ul>

        <tfoot id='jZm4e'></tfoot>
      1. <small id='jZm4e'></small><noframes id='jZm4e'>

        <legend id='jZm4e'><style id='jZm4e'><dir id='jZm4e'><q id='jZm4e'></q></dir></style></legend>
        <i id='jZm4e'><tr id='jZm4e'><dt id='jZm4e'><q id='jZm4e'><span id='jZm4e'><b id='jZm4e'><form id='jZm4e'><ins id='jZm4e'></ins><ul id='jZm4e'></ul><sub id='jZm4e'></sub></form><legend id='jZm4e'></legend><bdo id='jZm4e'><pre id='jZm4e'><center id='jZm4e'></center></pre></bdo></b><th id='jZm4e'></th></span></q></dt></tr></i><div id='jZm4e'><tfoot id='jZm4e'></tfoot><dl id='jZm4e'><fieldset id='jZm4e'></fieldset></dl></div>
      2. 如何判断一个日期是否在另外两个日期之间?

        How to tell if a date is between two other dates?(如何判断一个日期是否在另外两个日期之间?)
        <i id='pBULs'><tr id='pBULs'><dt id='pBULs'><q id='pBULs'><span id='pBULs'><b id='pBULs'><form id='pBULs'><ins id='pBULs'></ins><ul id='pBULs'></ul><sub id='pBULs'></sub></form><legend id='pBULs'></legend><bdo id='pBULs'><pre id='pBULs'><center id='pBULs'></center></pre></bdo></b><th id='pBULs'></th></span></q></dt></tr></i><div id='pBULs'><tfoot id='pBULs'></tfoot><dl id='pBULs'><fieldset id='pBULs'></fieldset></dl></div>
        <tfoot id='pBULs'></tfoot>

            <tbody id='pBULs'></tbody>

              <bdo id='pBULs'></bdo><ul id='pBULs'></ul>

              <small id='pBULs'></small><noframes id='pBULs'>

            • <legend id='pBULs'><style id='pBULs'><dir id='pBULs'><q id='pBULs'></q></dir></style></legend>

                  本文介绍了如何判断一个日期是否在另外两个日期之间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有以下代码:

                  if date in (start, end):
                          print('in between')
                  else:
                          print('No!')
                  

                  date、start和end都是1/1格式的变量.我应该怎么做才能打印出正确的结果?我尝试将日期设置为 10/2,从 3/14 开始,到 11/7 结束,它打印的是否!",这意味着它运行不正确.我想必须将它们格式化为日期格式,然后进行比较.

                  date, start and end are all variables with the format of 1/1. What should I do to have it print out the right result? i tried date as 10/2, start as 3/14 and end as 11/7 and it's print 'No!', which means it's not running right. I guess have to format them to a date format and then compare them.

                  推荐答案

                  既然你还不满意,我再给你一个答案.不使用日期时间和年份.

                  As you are still not satisfied, I have another answer for you. Without using datetime and year.

                  它只是使用内置元组并比较它们:

                  It just uses built-in tuples and comparing them:

                  d1 = (3, 28)
                  d2 = (3, 31)
                  d3 = (4, 2)
                  if d1 < d2 < d3:
                      print("BETWEEN!")
                  else:
                      print("NOT!")
                  

                  您可以轻松地创建这样的元组:

                  You can create tuple like these easily:

                  day = 16
                  month = 4
                  d = (month, day)
                  

                  这篇关于如何判断一个日期是否在另外两个日期之间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                  Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                  Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                  Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                  Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                  Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)

                      <small id='bXR7s'></small><noframes id='bXR7s'>

                        <bdo id='bXR7s'></bdo><ul id='bXR7s'></ul>
                        • <i id='bXR7s'><tr id='bXR7s'><dt id='bXR7s'><q id='bXR7s'><span id='bXR7s'><b id='bXR7s'><form id='bXR7s'><ins id='bXR7s'></ins><ul id='bXR7s'></ul><sub id='bXR7s'></sub></form><legend id='bXR7s'></legend><bdo id='bXR7s'><pre id='bXR7s'><center id='bXR7s'></center></pre></bdo></b><th id='bXR7s'></th></span></q></dt></tr></i><div id='bXR7s'><tfoot id='bXR7s'></tfoot><dl id='bXR7s'><fieldset id='bXR7s'></fieldset></dl></div>

                          <legend id='bXR7s'><style id='bXR7s'><dir id='bXR7s'><q id='bXR7s'></q></dir></style></legend>

                          <tfoot id='bXR7s'></tfoot>

                            <tbody id='bXR7s'></tbody>