Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40245
| References | <CAJ2vgs6zZpHC_p=SuE7QWf7NDvokMjmE1N-aEN3a6n_DXi2=aQ@mail.gmail.com> <CAJ2vgs59t2fkV_T-Kdcb5Mzsr5Q8M8z4P6NwMOftg-Y5zVR8wA@mail.gmail.com> <CAJ2vgs6dawhdDuz7HseGQA+1GPcmY4U2esgYBQzpH2HMOsgfnA@mail.gmail.com> |
|---|---|
| Date | 2013-03-01 12:25 +0100 |
| Subject | Re: Issue with continous incrementing of unbroken sequence for a entire working day |
| From | Morten Engvoldsen <mortenengv@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2717.1362137104.2939.python-list@python.org> (permalink) |
Hi,
I have wrote the below code for getting the serial number: look like i
am able to get correct serial number:
from datetime import date
def read_data_file():
with open("workfile.txt", 'r') as f:
for line in f.readlines():
read_data = line.split(' ')
return read_data
def write_data_file(data):
fo = open("workfile.txt", "w")
fo.write(str(data))
fo.close()
def comput_date(read_date, now_time, read_serial):
if read_date == now_time:
read_serial = int(read_serial)
return read_serial + 1
else:
read_serial = 1
return read_serial
def process_sales_record():
now_time = time.strftime("%d-%m-%y")
readdata = read_data_file()
if readdata:
read_serial = readdata[0]
read_date = readdata[1]
copute_date = comput_date(read_date, now_time, read_serial)
serial_number = copute_date
print serial_number
sales_recrod = {'record1':'product1',
'record2':'product2','record3':'product3'}
for i in sales_recrod:
print sales_recrod[i]
serial_number += 1
print serial_number
data = str(serial_number) + ' ' + now_time
writedata = write_data_file(data)
print readdata
Kindly suggest how can i improve this code now.... or is it okey in this way..
On Fri, Mar 1, 2013 at 10:42 AM, Morten Engvoldsen <mortenengv@gmail.com> wrote:
> Hi,
> Thanks.. :)
> so simply i can use time.strftime("%d%-m-%y %H:%M") , and then i can
> compare the date....
>
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Issue with continous incrementing of unbroken sequence for a entire working day Morten Engvoldsen <mortenengv@gmail.com> - 2013-03-01 12:25 +0100
csiph-web