>>> d = {1: u'\n25 \u0434\u0435\u043a\n\u0412\u0441\n\u0440\u0443\u0431.26,518\n',
... 2: u'\n26 \u0434\u0435\u043a\n\u041f\u043d\n\u0440\u0443\u0431.26,518\n',
... 3: u'\n27 \u0434\u0435\u043a\n\u0412\u0442\n\u0440\u0443\u0431.26,518\n',
... 4: u'\n28 \u0434\u0435\u043a\n\u0421\u0440\n\u0440\u0443\u0431.26,518\n',
... 5: u'\n29 \u0434\u0435\u043a\n\u0427\u0442\n\u0440\u0443\u0431.116,612\n',
... 6: u'\n30 \u0434\u0435\u043a\n\u041f\u0442\n\u0440\u0443\u0431.118,116\n',
... 7: u'\n31 \u0434\u0435\u043a\n\u0421\u0431\n - \n',
... 8: u'\n01 \u044f\u043d\u0432\n\u0412\u0441\n\u0440\u0443\u0431.16,980\n',
... 9: u'\n02 \u044f\u043d\u0432\n\u041f\u043d\n\u0440\u0443\u0431.118,115\n',
... 10: u'\n03 \u044f\u043d\u0432\n\u0412\u0442\n\u0440\u0443\u0431.16,975\n',
... 11: u'\n04 \u044f\u043d\u0432\n\u0421\u0440\n\u0440\u0443\u0431.37,928\n',
... 12: u'\n05 \u044f\u043d\u0432\n\u0427\u0442\n\u0440\u0443\u0431.16,978\n',
... 13: u'\n06 \u044f\u043d\u0432\n\u041f\u0442\n\u0440\u0443\u0431.51,238\n',
... 14: u'\n07 \u044f\u043d\u0432\n\u0421\u0431\n\u0440\u0443\u0431.18,898\n',
... 15: u'',
... 16: u'',
... 17: (u'\u0417\u043d\u0430\u0447\u043e\u043a \u043e\u0437\u043d\u0430\u0447'
... u'\u0430\u0435\u0442 \u043a\u043e\u0434-\u0448\u0435\u0440 \u0440\u0435'
... u'\u0439\u0441.'),
... 18: (u'\u0421\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0439 \u0446\u0435'
... u'\u043d\u0442\u0440')}
>>>
>>> for k in d:
... print k, '->', d[k]
...
1 ->
25 дек
Вс
руб.26,518
2 ->
26 дек
Пн
руб.26,518
3 ->
27 дек
Вт
руб.26,518
4 ->
28 дек
Ср
руб.26,518
5 ->
29 дек
Чт
руб.116,612
6 ->
30 дек
Пт
руб.118,116
7 ->
31 дек
Сб
-
8 ->
01 янв
Вс
руб.16,980
9 ->
02 янв
Пн
руб.118,115
10 ->
03 янв
Вт
руб.16,975
11 ->
04 янв
Ср
руб.37,928
12 ->
05 янв
Чт
руб.16,978
13 ->
06 янв
Пт
руб.51,238
14 ->
07 янв
Сб
руб.18,898
15 ->
16 ->
17 -> Значок означает код-шер рейс.
18 -> Сервисный центр
>>>
>>> def g():
... while True:
... yield 'a'
... yield 'b'
... yield 'c'
...
>>> list(zip(g(), range(10)))
[('a', 0), ('b', 1), ('c', 2), ('a', 3), ('b', 4), ('c', 5), ('a', 6), ('b', 7), ('c', 8), ('a', 9)]
>>>
#!/usr/bin/env python3
print('Content-type: text/html; charset=utf-8')
print()
print('<h1>Hello world!</h1>')
a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
b = {20, 3, 4, 23, 11, 17, 55, 8}
print('<p>A =', a)
print('<p>B =', b)
print('<p>Объединение Множеств A и B =', a | b)
[guest@localhost serv]$ ll
итого 4
drwxrwxr-x. 2 guest guest 4096 авг 11 11:43 cgi-bin
[guest@localhost serv]$ ll cgi-bin/
итого 4
-rwxrwxr-x. 1 guest guest 289 авг 11 11:43 script.py
[guest@localhost serv]$
[guest@localhost serv]$ python3 -m http.server --cgi
Serving HTTP on 0.0.0.0 port 8000 ...
127.0.0.1 - - [11/Aug/2016 11:45:30] "GET /cgi-bin/script.py HTTP/1.1" 200 -
>>> import datetime
>>>
>>> lst = [[datetime.datetime(2016, 6, 19, 23, 5, 33, 899000),
... datetime.datetime(2016, 6, 19, 23, 5, 33, 897000)],
... [datetime.datetime(2016, 7, 31, 19, 29, 56, 608000),
... datetime.datetime(2016, 7, 31, 19, 29, 56, 605000)]]
>>>
>>> list(map(min, lst))
[datetime.datetime(2016, 6, 19, 23, 5, 33, 897000), datetime.datetime(2016, 7, 31, 19, 29, 56, 605000)]
>>>
Как понять рекурсию в Python?
>>> numbers = (1, 2, 3)
>>> fnames = ('file{}.txt'.format(i) for i in numbers)
>>> files = [open(i, 'w', encoding='utf-8') for i in fnames]
>>> files
[<_io.TextIOWrapper name='file1.txt' mode='w' encoding='utf-8'>, <_io.TextIOWrapper name='file2.txt' mode='w' encoding='utf-8'>, <_io.TextIOWrapper name='file3.txt' mode='w' encoding='utf-8'>]
>>> [i.close() for i in files]
[None, None, None]
>>>
[guest@localhost t]$ ls
file1.txt file2.txt file3.txt
[guest@localhost t]$
>>> import operator
>>>
>>> def split3(x):
... return (x // 100, x // 10 % 10, x % 10)
...
>>> def split6(x):
... return (x // 1000, x % 1000)
...
>>> pred = lambda x: operator.eq(*map(sum, map(split3, split6(x))))
>>>
>>> out = list(filter(pred, range(100000, 1000000)))
>>> out[:10]
[100001, 100010, 100100, 101002, 101011, 101020, 101101, 101110, 101200, 102003]
>>>
>>> a = ['1', '2', '3333', '4', '5']
>>> b = ['●', '●', '●', '●', '●']
>>> align = list(map(len, a))
>>>
>>> def make_line(seq, aligns):
... return ' '.join('{0:>{1}}'.format(i, j) for i, j in zip(seq, aligns))
...
>>> out = '\n'.join((make_line(a, align), make_line(b, align)))
>>> print(out)
1 2 3333 4 5
● ● ● ● ●
>>>
>>> class Person:
... first_name = 'First'
... last_name = 'Last'
...
... @property
... def full_name_1(self):
... return ' '.join([self.first_name, self.last_name])
...
... def full_name_2(self):
... return ' '.join([self.first_name, self.last_name])
...
>>> p = Person()
>>> p.full_name_1
'First Last'
>>> p.full_name_2()
'First Last'
>>> p.full_name_2
<bound method Person.full_name_2 of <__main__.Person object at 0xb739a5ec>>
>>>