Python程序以不同于英语的语言显示消息 [英] Python program displaying messages in different language than english

查看:72
本文介绍了Python程序以不同于英语的语言显示消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个简单的python程序,版本为2.7.6(32位).但是,当我在消息框中显示任何消息时,它会以某种奇怪的语言出现.代码在下面

I have written a simple python program in version 2.7.6 (32 bit). But when i display any message in a message box it comes in some weird language. The code is below

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)

这是输出

推荐答案

您需要发送一个unicode字符串;因为您使用的是消息框 MessageBoxW 的unicode版本,所以如果要发送普通的ascii字符串,则需要使用 MessgeBoxA

You need to send a unicode string; because you are using the unicode version of message box MessageBoxW, if you want to send normal ascii strings you need to use MessgeBoxA

ctypes.windll.user32.MessageBoxA(None, 'Hello', 'Window title', 0) # or
ctypes.windll.user32.MessageBoxW(None, u'Hello', u'Window title', 0)

这篇关于Python程序以不同于英语的语言显示消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆