当前位置:网站首页>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
边栏推荐
- Kafka-connect将Kafka数据同步到Mysql
- Basic realization of line graph
- Share a latex online editor | with latex common templates
- Kindle operation: transfer downloaded books and change book cover
- 2022 free test questions of fusion welding and thermal cutting and summary of fusion welding and thermal cutting examination
- 2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
- Cs5212an design display to VGA HD adapter products | display to VGA Hd 1080p adapter products
- Different methods for setting headers of different pages in word (the same for footer and page number)
- Chapter IV decision tree
- Ag9310meq ag9310mfq angle two USB type C to HDMI audio and video data conversion function chips parameter difference and design circuit reference
猜你喜欢
The beauty of Mathematics -- the principle of fine Fourier transform
USB type-C docking design | design USB type-C docking scheme | USB type-C docking circuit reference
10. CNN applied to handwritten digit recognition
2022 safety officer-a certificate free examination questions and safety officer-a certificate mock examination
General configuration tooltip
Definition and classification of energy
Common effects of line chart
Know how to get the traffic password
2022 safety officer-c certificate examination summary and safety officer-c certificate reexamination examination
Macro definition and multiple parameters
随机推荐
Know how to get the traffic password
For the first time in China, three Tsinghua Yaoban undergraduates won the stoc best student thesis award
Smart grid overview
11. Recurrent neural network RNN
Common effects of line chart
Get started quickly using the local testing tool postman
5. Over fitting, dropout, regularization
Saving and reading of network model
Led serial communication
The examination contents of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge) in 2021 and the free examination questions of the third batch of Guangdong Prov
Chapter 5 neural network
Recommend a document management tool mendely Reference Manager
Swift get URL parameters
2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
Gnuradio3.9.4 create OOT module instances
Vscode is added to the right-click function menu
Smart agricultural technology framework
Common configurations in rectangular coordinate system
USB type-C docking design | design USB type-C docking scheme | USB type-C docking circuit reference
130. 被围绕的区域