import random
n, rand_min, rand_max = 12, 1, 99
a, b, c = [], [], []
for i in range(0, n):
a.append(random.randint(rand_min, rand_max))
print('Массив: %s' % a)
m = n // 2
if n % 2 > 0:
k = 1
else:
k = 0
for i in range(n - m - k, n):
b.append(a[i])
for i in range(0, m):
c.append(a[i])
print('Первая половина: %s' % c)
print('Вторая половина: %s' % b)
print('Перевернутые половины: %s' % (b + c))
два объекта с непересекающимся временем жизни могут иметь одинаковый id
agluhov@forge:~$ python
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> s = 'test_string'
>>> id(s[1:5]) == id(s[2:6])
True
>>> id(s[1:5])
139620785926528
>>> id(s[2:6])
139620785926528
>>> print(id(s[1:5]))
139620785926384
>>> print(id(s[2:6]))
139620785926576
>>> print(id(s[1:5]), id(s[2:6]))
(139620785926528, 139620785926528)
from telethon import TelegramClient
api_id = 000000 # integer
api_hash = '' # string
phone_number = '' # strings
if __name__ == '__main__':
client = TelegramClient('history_lurker', api_id=api_id, api_hash=api_hash)
client.connect()
if not client.is_user_authorized():
client.send_code_request(phone_number)
client.sign_in(phone_number, input('Enter code: '))
chat = InputPeerChat(chat_id)
count, messages, senders = client.get_message_history('Stickers', limit=5)
for message in messages:
print(message.id, message.message)
pip install pygame
import pygame
_PNG_IMAGE = 'kitten-and-puppy.png'
pygame.display.init()
img = pygame.image.load(_PNG_IMAGE)
screen = pygame.display.set_mode(img.get_size(), pygame.FULLSCREEN)
screen.blit(img, (0, 0))
pygame.display.flip()
input()
pygame.quit()
pip install --upgrade pip
pip install pyqt5 pyqt5-tools