社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

尝试将今天的日期与python中的自定义日期列表匹配

Nithin Reddy • 3 年前 • 1125 次点击  

尝试将今天的日期与python中的自定义日期列表匹配

代码是:

holid = ['2021-01-26', '2021-03-11', '2021-03-29', '2021-04-02', '2021-04-14', '2021-04-21',
 '2021-05-13', '2021-07-21', '2021-08-19', '2021-09-10', '2021-10-15', '2021-11-05','2021-11-19']

date = datetime.today().strftime('%Y-%m-%d')
date

'2021-06-06'

for i in holid:
    i == date
    print("Matched")

它返回了错误的输出:

Matched
Matched
Matched
Matched
Matched
Matched
Matched
Matched
Matched
Matched
Matched
Matched
Matched
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/133597
 
1125 次点击  
文章 [ 2 ]  |  最新文章 3 年前