On this page
ctypes.string_at
Prev: ctypes.sizeof | Up: ctypes | Next: ctypes.wstring_at
Rel: ctypes.addressof, ctypes.alignment, ctypes.ArgumentError, ctypes.Array
Ref: docs.python.org — ctypes.string_at
Tags: #public #python3 #stdlib #ctypes
Import
import ctypes
from ctypes import string_at
Signature & Overview
ctypes.string_at(ptr, size=-1)
Return the byte string at void *ptr.
Usage
import ctypes
buf = ctypes.create_string_buffer(b"hello\x00world", 12)
assert ctypes.string_at(buf) == b"hello"
assert ctypes.string_at(buf, 11) == b"hello\x00world"
Gotchas
- Pass explicit
size=for binary data containing NUL bytes: Withoutsize,string_at()stops at the first\x00.
REPL Inspect
from ctypes import string_at
help(string_at)
Linked from
Related notes
- tuts/python3/stdlib_module/ctypes/sizeof Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/wstring_at Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ctypes/addressof Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/alignment Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/ArgumentError Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/Array Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianStructure shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianUnion shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/byref shared tags: #ctypes, #stdlib