Vishal Mahajan Vishal Mahajan - 1 year ago 87
Python Question

Python code to run for next 100 days from today

I want to run below line of code for 200 days from today.
Suppose today is 1st days so my code is-

line = linecache.getline("lines1.txt",1)

Suppose today is 2nd days so my code is-

line = linecache.getline("lines1.txt",2)

Suppose today is 3rd days so my code becomes-

line = linecache.getline("lines1.txt",3)

I want above 1,2,3,4,5......200 to be calculated everyday. I don't want a loop to run for 200 days.

I just need to get 1,2,3,4,5......200 count from python Date system or any other counting system.

Answer Source

set a marker date then calculated difference between today dan marker date

(datetime.datetime(2016,9,2) - datetime.datetime(2016,9,1) ).days
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download