Wacky_rubia

импорт в питон

Nov 27th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. from cffi import FFI
  3. ffi = FFI()
  4. ffi.cdef("""
  5. void hello(char name[]); // copy-pasted from the man page
  6. """)
  7. my_lib = ffi.dlopen('./hello') # loads the entire C namespace
  8. arg = ffi.new("char[]", b"from Python") # equivalent to C code: char arg[] = "world";
  9. my_lib.hello(arg)
  10. # print("Hello!")
Advertisement
Add Comment
Please, Sign In to add comment