动态链接库
三种加载方式
cdll()
windll()
oledll()
在Max OX系统上的使用
1 | from ctypes import * |
2 | libc = CDLL("libc.dylib") |
3 | # libc = cdll.LoadLibrary('libc.dylib') |
4 | # libc = cdll.LoadLibrary('/usr/lib/libc.dylib') |
上述三种方式都可以
1 | message_string = "Hello world!\n" |
2 | libc.printf("Testing: %s", message_string) |
3 | # 输出: |
4 | # H |
没错! 只输出第一个letter! 只有在每个字符创前都加上b
后才正常
1 | message_string = b"Hello world!\n" |
2 | libc.printf(b"Testing: %s", message_string) |
The small detail of the
b
prefix, which is a bytes literal, is the difference between passing an ASCII byte stringb"Hello World!\n"
versus a UTF-16LE encoded string