different behavior from idle/pycharm and shell
python at mrabarnett.plus.com
Mon Oct 27 23:55:21 CET 2014
On 2014-10-27 22:38, kiuhnm03 at yahoo.it wrote:
> Consider this code:
> from ctypes import *
> user32 = windll.user32
> user32.MessageBoxA(0, 'ok', 'ok', 0)
> If I run it in idle or from pycharm, the messagebox shows 'o' instead of 'ok', but if I run it from shell, it shows 'ok' like it should.
> The same happens with msvcrt.printf().
You didn't say whether you're using Python 2 or Python 3, but it looks
like you're using Python 3.
There are 2 forms of the MessageBox function, one with the suffix 'A',
which uses bytestrings, and one with the suffix 'W', which uses Unicode
In Python 3, the str class is a Unicode string, so you'll want the
from ctypes import *
user32 = windll.user32
user32.MessageBoxW(0, 'ok', 'ok', 0)
Also, the msvcrt.printf function expects a bytestring.
More information about the Python-list