I coded this little Script while reading „Hacking with Python“ from Justin Seitz. I got the following error:

from ctypes import *
msvcrt = cdll.msvcrt
message_string = b"Hallo, Welt \n"
msvcrt.printf(b"Test: %s", message_string)
Output in IDLE3 interactivly:
19

or IDLE3 directly:
====================== Restart: C:\Users\TN\Desktop\ctayps.py ====================== 

Answer:

printf writes the output not to the sys.stdout in Python like normal, it writes the output to the operating system std.out. So You have to start your script in the cmd directly.

ctypes
click to enlarge

Source: https://www.cs.auckland.ac.nz/references/python/3.2.3-docs/library/ctypes.html#calling-functions-continued

Justin Seitz: Hacking with Python

[Python3|ctypes] printf() doesnt print on screen or it counts | IDLE IDLE3 PythonWin
Markiert in: