Long puzzled, but I just can not understand what I'm doing wrong.
There is a file with dates of type:
16 Октября 2014 19:21 16 Октября 2014 18:46 16 Октября 2014 18:41 16 Октября 2014 17:18 .......
from DATEspliter import DATE dates=[] o = open('date.txt').readlines() for elem in o: dates.append(elem) d = DATE(elem) if d.Month() == ['Октября']: date = {str(d.Clock()[0]):elem.strip()} Year['okt'][int(d.Day()[0])].update(date) if d.Month() == ['Сентября']: date = {str(d.Clock()[0]):elem.strip()} Year['spt'][int(d.Day()[0])].update(date) There is a Year dictionary with the keys 'okt', 'spt' ...
It is necessary to push a certain month in a certain key.
All is good, but my code either shoves one October in both dictionaries, or both October and September in both, as I have not tried. Although if you display an elem in each if, it "sows" them correctly. The print function proves it.
[0]everywhere. It is worth mentioning whyDATEused instead ofdatetimefrom the standard library. Ideally, to bring a small self-contained script that demonstrates the problem and which can be run separately (for example, use datetime.date to avoid dependence on DATESpl - jfs