Advertisement
Guest User

new

a guest
Feb 24th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. #include <Python.h>
  2.  
  3. int
  4. main(int argc, char *argv[])
  5. {
  6.     wchar_t *program = Py_DecodeLocale(argv[0], NULL);
  7.     if (program == NULL) {
  8.         fprintf(stderr, "Fatal error: cannot decode argv[0]\n");
  9.         exit(1);
  10.     }
  11.     Py_SetProgramName(program);  /* optional but recommended */
  12.     Py_Initialize();
  13.     PyRun_SimpleString("from time import time,ctime\n"
  14.                        "print('Today is', ctime(time()))\n");
  15.     if (Py_FinalizeEx() < 0) {
  16.         exit(120);
  17.     }
  18.     PyMem_RawFree(program);
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement