当前位置:网站首页>AttributeError: ‘str‘ object has no attribute ‘strftime‘
AttributeError: ‘str‘ object has no attribute ‘strftime‘
2022-07-08 01:24:00 【Bosong】
from datetime import datetime, date
now_date = '2021-6-24 15:23:29.000227'
nowdate = now_date.strftime(now_date,"%m/%d/%Y")
Want to get only... From the moment represented by a string “ year / month / Japan ”, But running the above code will report an error 'str' object has no attribute 'strftime'.
The improvement method is as follows :
now_date = datetime.strptime(now_date, '%Y-%m-%d %H:%M:%S.%f')
now_date = now_date.strftime("%m/%d/%Y")
We need to use it first. .strptime() take string Format variables into datetime Time format under , And then reuse it .strftime() obtain “ year / month / Japan ”.
PS: If you want to get the day of the week today ,datetime.strptime().weekday() + 1
边栏推荐
- The whole life cycle of commodity design can be included in the scope of industrial Internet
- Leetcode notes No.7
- Markdown learning (entry level)
- 130. 被圍繞的區域
- The combination of relay and led small night light realizes the control of small night light cycle on and off
- C# ?,?.,?? .....
- Basic realization of line chart (II)
- 1. Linear regression
- The communication clock (electronic time-frequency or electronic time-frequency auxiliary device) writes something casually
- FIR filter of IQ signal after AD phase discrimination
猜你喜欢
2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
跨模态语义关联对齐检索-图像文本匹配(Image-Text Matching)
Chapter 16 intensive learning
133. 克隆图
1. Linear regression
2022 chemical automation control instrument examination summary and chemical automation control instrument simulation examination questions
Parade ps8625 | replace ps8625 | EDP to LVDS screen adapter or screen drive board
Blue Bridge Cup embedded (F103) -1 STM32 clock operation and led operation method
2022 refrigeration and air conditioning equipment operation examination questions and refrigeration and air conditioning equipment operation examination skills
Chapter 7 Bayesian classifier
随机推荐
Guojingxin center "APEC investment +": some things about the Internet sector today | observation on stabilizing strategic industrial funds
2021 welder (primary) examination skills and welder (primary) operation examination question bank
解决报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Kafka-connect将Kafka数据同步到Mysql
Guojingxin center "APEC education +" Shanghai Jiaotong University Japan Cooperation Center x Fudan philosophy class "Zhe Yi" 2022 New Year greetings
133. 克隆图
EDP to LVDS conversion design circuit | EDP to LVDS adapter board circuit | capstone/cs5211 chip circuit schematic reference
Multi purpose signal modulation generation system based on environmental optical signal detection and user-defined signal rules
2022 safety officer-c certificate examination summary and safety officer-c certificate reexamination examination
跨模态语义关联对齐检索-图像文本匹配(Image-Text Matching)
130. 被围绕的区域
11. Recurrent neural network RNN
Vs code configuration latex environment nanny level configuration tutorial (dual system)
Smart grid overview
Apt get error
Ag9310 same function alternative | cs5261 replaces ag9310type-c to HDMI single switch screen alternative | low BOM replaces ag9310 design
2022 chemical automation control instrument examination summary and chemical automation control instrument simulation examination questions
14. Draw network model structure
130. 被圍繞的區域
Basic realization of line chart (II)