a = b'\x7e\x41\x01\x00\x00\x00\x00\x00\x10\x1d\x43\xa1\x5f\x01\x1d\x43\xa1\x5f\x30\xc4\x55\x01\xf0\xa8\xfb\x01\x00\x00\x00\x00\x00\x00\xe4'
Size,numPage,Code,Time,StateGauge,LastTime,Lat,Lon,Speed,Course, = struct.unpack("<2xBIHIBIIIHH",a[:30])
a = [] #список
a[0] = 1 #ошибка потому что в списке нет 0 элемента и вообще никаких нет.
b = {} #словарь
b[0] = 1 #нет ошибки потому что отсутсвующие ключи словаря создаются в такой конструкции
a = [None]*100
a[0] = 1 #теперь ошибки нет потому что в списке 100 элементов None
a[100] = 1 #снова ошибка потому что индекс 100 это 101 элемент по порядку, которого нет
\"Описание показателя\" varchar(150), \
\"Блок данных\" varchar(30), \
pokaz_descr varchar(150), \
data_block varchar(30), \
mystr="Test string for me"
arr = [ord(x) for x in mystr]
print(arr)
arr = [int(sum(arr)/len(arr))]+arr
print(arr)
arr += [x for x in [ord(x) for x in (input()+" ")[:3]] if x not in arr]
print(arr)
if arr[-1] in arr[:-1]: print("count Last:",arr.count(arr[-1])-1)
arr.sort(reverse=True)
print(arr)
from PIL import Image, ImageDraw
def round_corner(radius, fill):
"""Draw a round corner"""
corner = Image.new('RGBA', (radius, radius), (0, 0, 0, 0))
draw = ImageDraw.Draw(corner)
draw.pieslice((0, 0, radius * 2, radius * 2), 180, 270, fill=fill)
return corner
def procent_line(size, radius, fill1, fill2, p):
"""Draw a rounded rectangle"""
width, height = size
rectangle = Image.new('RGBA', size, fill2)
corner_b = round_corner(radius, fill2)
corner_f = round_corner(radius, fill1)
rectangle.paste(corner_f, (0, 0))
rectangle.paste(corner_f.rotate(90), (0, height - radius)) # Rotate the corner and paste it
rectangle.paste(corner_b.rotate(180), (width - radius, height - radius))
rectangle.paste(corner_b.rotate(270), (width - radius, 0))
rectangle.paste(corner_f.rotate(180), (int(width*p - radius), height - radius),corner_f.rotate(180))
rectangle.paste(corner_f.rotate(270), (int(width*p - radius), 0),corner_f.rotate(270))
ImageDraw.Draw(rectangle).rectangle([radius,0,int(width*p - radius),height],fill=fill1)
return rectangle
img = procent_line((400, 40), 20, "yellow", "gray", .25)
img.show()