当前位置:网站首页>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
边栏推荐
- 2022 safety officer-c certificate examination summary and safety officer-c certificate reexamination examination
- Chapter VIII integrated learning
- The beauty of Mathematics -- the principle of fine Fourier transform
- Su embedded training - C language programming practice (implementation of address book)
- Vscode is added to the right-click function menu
- STM32GPIO口的工作原理
- Ag9310 same function alternative | cs5261 replaces ag9310type-c to HDMI single switch screen alternative | low BOM replaces ag9310 design
- Redis master-slave replication
- A speed Limited large file transmission tool for every major network disk
- Authorization code of Axure rp9
猜你喜欢
2022 low voltage electrician examination content and low voltage electrician simulation examination question bank
Blue Bridge Cup embedded (F103) -1 STM32 clock operation and led operation method
130. Surrounding area
USB type-C docking design | design USB type-C docking scheme | USB type-C docking circuit reference
2、TD+Learning
Y59. Chapter III kubernetes from entry to proficiency - continuous integration and deployment (III, II)
Basic realization of line graph
Gnuradio3.9.4 create OOT module instances
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
4. Apprentissage stratégique
随机推荐
General configuration tooltip
Common fault analysis and Countermeasures of using MySQL in go language
4、策略學習
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
Y59. Chapter III kubernetes from entry to proficiency - continuous integration and deployment (III, II)
2021-03-14 - play with generics
The whole life cycle of commodity design can be included in the scope of industrial Internet
Common configurations in rectangular coordinate system
2022 chemical automation control instrument examination summary and chemical automation control instrument simulation examination questions
2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
130. Surrounding area
2022 safety officer-c certificate examination paper and safety officer-c certificate simulated examination question bank
【深度学习】AI一键换天
1. Linear regression
2021 tea master (primary) examination materials and tea master (primary) simulation test questions
Swift get URL parameters
Design method and application of ag9311maq and ag9311mcq in USB type-C docking station or converter
Su embedded training - Day6
Kindle operation: transfer downloaded books and change book cover
Cs5212an design display to VGA HD adapter products | display to VGA Hd 1080p adapter products