我已經安裝了Python 2.7.3和PyScripter。在交互shell在Python中打印簡單消息
from ctypes import *
msvcrt = cdll.msvcrt
message_string = "Hello world!\n"
msvcrt.printf("Testing: %s".encode('ascii'), message_string.encode('ascii')
(也試過不編碼)
我已經安裝了Python 2.7.3和PyScripter。在交互shell在Python中打印簡單消息
from ctypes import *
msvcrt = cdll.msvcrt
message_string = "Hello world!\n"
msvcrt.printf("Testing: %s".encode('ascii'), message_string.encode('ascii')
(也試過不編碼)
工作對我來說: 當我試圖運行這個簡單的代碼,該interupter不顯示任何
>>> msvcrt.printf("Testing: %s".encode('ascii'), message_string.encode('ascii'))
Testing: Hello World!
22
嘗試把它在一個.py文件,然後從CMD
python C:\path\to\file
你已經錯過了一個尾架'運行)'用於'printf'函數。或者這是一個格式錯誤? – TerryA
感謝您的快速響應。這是一個格式錯誤,抱歉。 – Shpongle
你對'import sys;打印類型(sys.stdout)'? – eryksun