当前位置:网站首页>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
边栏推荐
- Ag9311maq design 100W USB type C docking station data | ag9311maq is used for 100W USB type C to HDMI with PD fast charging +u3+sd/cf docking station scheme description
- Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small
- USB type-C mobile phone projection scheme | USB type-C docking station scheme | TV / projector type-C converter scheme | ag9300ag9310ag9320
- The Ministry of housing and urban rural development officially issued the technical standard for urban information model (CIM) basic platform, which will be implemented from June 1
- y59.第三章 Kubernetes从入门到精通 -- 持续集成与部署(三二)
- Su embedded training - C language programming practice (implementation of address book)
- The solution of frame dropping problem in gnuradio OFDM operation
- Ag9310 design USB type C to hdmi+u2+5v slow charging scheme design | ag9310 expansion dock scheme circuit | type-C dongle design data
- 4、策略学习
- General configuration tooltip
猜你喜欢
【深度学习】AI一键换天
Ag9310meq ag9310mfq angle two USB type C to HDMI audio and video data conversion function chips parameter difference and design circuit reference
STM32GPIO口的工作原理
Macro definition and multiple parameters
Guojingxin center "APEC investment +": some things about the Internet sector today | observation on stabilizing strategic industrial funds
Getting started STM32 -- how to learn stm32
Arm bare metal
The beauty of Mathematics -- the principle of fine Fourier transform
How to write mark down on vscode
2021-03-14 - play with generics
随机推荐
On the concept and application of filtering in radar signal processing
Content of one frame
Understanding of sidelobe cancellation
2022 chemical automation control instrument examination summary and chemical automation control instrument simulation examination questions
High quality USB sound card / audio chip sss1700 | sss1700 design 96 kHz 24 bit sampling rate USB headset microphone scheme | sss1700 Chinese design scheme explanation
2021 welder (primary) examination skills and welder (primary) operation examination question bank
FIR filter of IQ signal after AD phase discrimination
Su embedded training - Day6
Basic realization of line chart (II)
Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small
Gnuradio 3.9 using OOT custom module problem record
Su embedded training - Day9
2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
Ag9310 same function alternative | cs5261 replaces ag9310type-c to HDMI single switch screen alternative | low BOM replaces ag9310 design
【深度学习】AI一键换天
Using GPU to train network model
Gnuradio transmits video and displays it in real time using VLC
2021-04-12 - new features lambda expression and function functional interface programming
2022 high voltage electrician examination skills and high voltage electrician reexamination examination
Gnuradio3.9.4 create OOT module instances