TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #242 · 7 мај

Теперь запакуем строку. В этом случае следует передавать тип данных 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

Hashtags

Резултати

Пронајдени 2 слични објави

Пребарај: #naturescience

当前筛选 #naturescience清除筛选
Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40824 · 18.03.2026 г., 20:32

Only about 30 locations worldwide feature singing dunes, primarily crescent-shaped barchans, found in deserts like the Gobi, Mojave, and Taklamakan. These dunes produce deep hums or musical notes when sand avalanches slide down their slopes. The sound happens as grains of sand rub together, creating vibrations amplified by the dune’s structure, much like a violin or cello. The sand must be dry, with grains that are uniform in size and spherical, allowing for optimal vibration transfer. Acting like a natural instrument, the dune resonates and amplifies the sound, which can be heard up to 10 km away. This unique phenomenon can last for minutes, depending on the dune. Not all dunes sing, as specific conditions—like dry sand and the right grain size—are required for the sound. 🎶🏜️🎵 [Read and hear more] [Read and see more] @googlefactss #SingingDunes#DesertSounds#NatureScience#GeologicalWonders#MusicalDunes#Dune

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40930 · 14.04.2026 г., 22:01

The Titicaca water frog (Telmatobius culeus) can absorb oxygen through its skin, an adaptation that helps it survive in the high-altitude waters of Lake Titicaca, where oxygen levels are low. This unique ability allows it to thrive in an environment where most other species struggle. The frog's skin is highly vascularized, increasing its efficiency at absorbing oxygen directly from the water. 💧🐸⛰️ [Read more] (Frog memes allowed here) @googlefactss #FrogFacts#TiticacaFrog#TelmatobiusCuleus#NatureScience#UniqueAdaptations#Amphibians#ItsWednesdayMyDudes If you have ideas or feedback contact us: @Googlefactss_Feedback_bot