我在2.7.6版(32位)中编写了一个简单的python程序.但是当我在消息框中显示任何消息时,它会出现一些奇怪的语言.代码如下
import Tkinter as tk
import win32com.client
import pythoncom
import ctypes
import sys
import glob
import sys
import os
MessageBox = ctypes.windll.user32.MessageBoxW
if __name__ == "__main__":
MessageBox(None, "Hello", 'Window title',0)
Run Code Online (Sandbox Code Playgroud)
这是输出
你需要发送一个unicode字符串; 因为您正在使用unicode版本的消息框MessageBoxW
,如果要发送需要使用的普通ascii字符串MessgeBoxA
ctypes.windll.user32.MessageBoxA(None, 'Hello', 'Window title', 0) # or
ctypes.windll.user32.MessageBoxW(None, u'Hello', u'Window title', 0)
Run Code Online (Sandbox Code Playgroud)