当前位置:网站首页>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
边栏推荐
- Understanding of sidelobe cancellation
- 4. Apprentissage stratégique
- Scheme selection and scheme design of multifunctional docking station for type C to VGA HDMI audio and video launched by ange in Taiwan | scheme selection and scheme explanation of usb-c to VGA HDMI c
- Smart grid overview
- 133. Clone map
- For the first time in China, three Tsinghua Yaoban undergraduates won the stoc best student thesis award
- 2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
- Authorization code of Axure rp9
- Su embedded training - Day9
- Gnuradio 3.9 using OOT custom module problem record
猜你喜欢

Chapter VIII integrated learning

2022 examination for safety production management personnel of hazardous chemical production units and new version of examination questions for safety production management personnel of hazardous chem

Su embedded training - Day6

130. 被围绕的区域

1. Linear regression

Smart grid overview

A speed Limited large file transmission tool for every major network disk

Getting started STM32 -- how to learn stm32

USB type-C docking design | design USB type-C docking scheme | USB type-C docking circuit reference

2021 Shanghai safety officer C certificate examination registration and analysis of Shanghai safety officer C certificate search
随机推荐
Capstone/cs5210 chip | cs5210 design scheme | cs5210 design data
2022 refrigeration and air conditioning equipment operation examination questions and refrigeration and air conditioning equipment operation examination skills
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
Generic configuration legend
Blue Bridge Cup embedded (F103) -1 STM32 clock operation and led operation method
Continued from the previous design
2022 R1 fast opening pressure vessel operation test question bank and R1 fast opening pressure vessel operation free test questions
Kuntai ch7511b scheme design | ch7511b design EDP to LVDS data | pin to pin replaces ch7511b circuit design
C# ?,?.,?? .....
Running OFDM in gnuradio_ RX error: gr:: Log: info: packet_ headerparser_ b0 - Detected an invalid packet at item ××
About how USRP sets the sampling frequency below the minimum sampling frequency reached by the hardware
Ag9310meq ag9310mfq angle two USB type C to HDMI audio and video data conversion function chips parameter difference and design circuit reference
STM32GPIO口的工作原理
The beauty of Mathematics -- the principle of fine Fourier transform
The combination of relay and led small night light realizes the control of small night light cycle on and off
Overall introduction of the project
Connect to the previous chapter of the circuit to improve the material draft
y59.第三章 Kubernetes从入门到精通 -- 持续集成与部署(三二)
5. Contrôle discret et contrôle continu
String usage in C #