How to record the starting and ending date and time at the beginning and ending of the file accordingly?
Your exact problem is unclear, but I will address an inferred question “How to time things in Python?” Hopefully you can use the guides to address your issue.
Time
It is common to see time recorded in the following idiom:
start = time.time()
# your code
end = time.time()
print("Duration: ", end - start)
You can get varying specificity depending on which time
object you use, e.g. time()
, monotonic()
, perf_counter()
, etc.
See also - Python Timer Functions: Three Ways to Monitor Your Code
Dates
Similarly, use datetime
where the “duration” is a timedelta
object. datetime
objects will include both date and time. From there you can customize how the timestamp is displayed.
See also - Using Python datetime to Work With Dates and Times
Thank you, This is exactly questioned about the project am working on:
"You also need to record the starting and ending date and time at the beginning and ending of the file
accordingly. It should also show the total time it took in the port scanning process
Let me know if you need further information.
Am using the Socket library.
While I can (just barely) understand your problem a bit more, you know it more than I do. More critically, this sounds like an assignment, so I won’t give a solution. However, the comment and guides I’ve mentioned should adequately equip you to solve this and many other time-related problems. Again, start with time
and datetime
libraries. I’m happy to see what you come up with
Cheers.
Thank you, I was able to figure it out… thank you so much !
Cecil Kimaro