Теперь запакуем строку.
В этом случае следует передавать тип данных bytes.
>>> struct.pack('=s', b'a')
b'a'
Для записи слова следует указывать количество символов.
>>> struct.pack('=5s', b'hello')
b'hello'
Кстати, запакованный вид соответствует исходному тексту. Всё верно, символ есть в таблице ASCII, то есть его код попадает в диапазон 0-127, он может быть записан одним байтом и имеет визуальное представление. А вот что будет если добавить символ вне ASCII
>>> struct.pack(f'=s', b'ё')
SyntaxError: bytes can only contain ASCII literal characters.
Ошибка возникла еще на этапе создания объекта bytes, который не может содержать такой символ. Поэтому надо кодировать эти байты из строки.
>>> enc = 'ёжик'.encode('utf-8')
>>> struct.pack(f'={len(enc)}s', enc)
b'\xd1\x91\xd0\xb6\xd0\xb8\xd0\xba'
Заметьте, длина такой строки в байтах отличается от исходной длины, так как символы вне ASCII записываются двумя байтами и более. Поэтому здесь формат создаём на лету, используя получившуюся длину как каунтер токена.
#libs#basic
⚡️Tether kompaniyasi Neuralink chiplariga o‘xshash texnologiya ustida ishlamoqda
⚡️ Tether kompaniyasi BrainOS deb nomlangan tizimni ishlab chiqayotganini e’lon qildi. Bu tizim inson aqlini sun’iy intellektning hisoblash imkoniyatlari bilan birlashtirishi mumkin.
⚡️ Kompaniyaning bashoratiga ko‘ra, yaqin 5–10 yil ichida sun’iy intellekt ko‘plab kasblarning ajralmas qismiga aylanadi va odamlar bunga moslashishga majbur bo‘ladi.
⚡️BrainOS bu muammoni hal qilish uchun taklif etilgan — texnologiyalarni to‘g‘ridan-to‘g‘ri inson miyasi bilan integratsiya qilish. Bu orqali fikrlash jarayoni tezlashadi va insoniyat sun’iy intellekt davrida yetakchilikni saqlab qolishi mumkin.
👉Bizning barcha loyihalar | #tether
CEO of #Tether warns about the possibility of mass mailing of phishing emails with the distribution of crypts
Hackers have hacked a "well-known" service provider for email newsletters (the name is not disclosed)
New investments by #Tether💵
Tether has invested $200 million in the biotech company Blackrock Neurotech, with a Brain-Computer-Interface (chipping, etc.. it looks like a Neuralink Mask)
Against the background of such investments by Blackrock Neurotech, Tether introduced its new division Tether Evo. The division will be engaged in investing in "human-oriented" technologies.
Earlier, Tether announced a new concept for the company, and also stated that they would invest in various areas of the global economy.
It is worth noting that Blackrock Neurotech has nothing to do with the Blackrock we know.
In general, biotechnology is an interesting investment direction, and Tether only confirms this + such movements pull the company beyond the framework of stablecoins.
Euro #Tether (EUR₮) and #Tether Gold (XAU₮) To Launch on BitMart Exchange
https://tether.to/en/euro-tether-eurt-and-tether-gold-xaut-to-launch-on-bitmart-exchange/
Euro #Tether (EURT) and #Tether Gold (XAUT) To Launch on SimpleSwap
https://tether.to/en/euro-tether-eurt-and-tether-gold-xaut-to-launch-on-simpleswap/