In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you the "python timestamp subtraction example analysis", the content is simple and easy to understand, clear organization, I hope to help you solve doubts, let Xiaobian lead you to study and learn "python timestamp subtraction example analysis" this article bar.
Time stamp subtraction
Record a time point before and after code execution, and subtract the two time stamps to calculate the running time of the program.
Get timestamp time.time()
import timestart_time = time.time()sum = 0for i in range(100000000): sum += iprint(sum)end_time = time.time()print("elapsed time: {:.2f} sec.".format(end_time - start_time)) Output: 4999995000000 elapsed time: 10.53 sec.
Get the current date datetime.datetime.now ()
import datetimestart_time = datetime.datetime.now()sum = 0for i in range(100000000): sum += iprint(sum)end_time = datetime.datetime.now ()print("Time: {} seconds".format(end_time - start_time)) Above is "Python timestamp subtraction example analysis" All the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.