Search notes:

Python standard library: struct

struct can be used to read or write binary data.

Writing integers

import struct

nums = [
   0x61626364,  # abcd in hex
   10,
   1, 256, 65536
]

with open('/tmp/struct.out', 'wb') as f:
     f.write(struct.pack( 'i' * len(nums), *nums))
$ od -t d4z --width=4 /tmp/struct.out
0000000  1633837924  >dcba<
0000004          10  >....<
0000010           1  >....<
0000014         256  >....<
0000020       65536  >....<
0000024

See also

standard library

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1745040963, '3.22.66.60', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/standard-library/struct(58): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78