我想使用 pyRevit 脚本以法语打印对话框。一旦我在我的代码中包含像“ê”这样的重音,pyRevit 脚本甚至不会执行。
但是,如果我在 RevitPythonShell 中打印“être”,没问题。
为什么?为什么要进行不同的处理,是否可以使用 pyRevit 处理?
非常感谢,阿诺。
我想使用 pyRevit 脚本以法语打印对话框。一旦我在我的代码中包含像“ê”这样的重音,pyRevit 脚本甚至不会执行。
但是,如果我在 RevitPythonShell 中打印“être”,没问题。
为什么?为什么要进行不同的处理,是否可以使用 pyRevit 处理?
非常感谢,阿诺。
这都是关于编码和解码的。我建议您阅读有关该主题的这篇精彩文章: http://sametmax.com/lencoding-en-python-une-bonne-fois-pour-toute/ 您应该在所有脚本前加上:#coding:utf8
# coding: utf8
__title__ = "TextEncoding"
print("être")
我不确定 PyRevit,但我可以在 RevitPythonShell 中制作 Revit 对话框时使用法语字符,如下所示:
dialog = TaskDialog("être")
dialog.MainContent = "être"
dialog.Show()
当像这样使用 Winforms 时:
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import Form, Label
form = Form()
form.Width = 300
form.Height = 100
label = Label()
label.Text = 'Here is some French Text: "être"'
label.Width = 280
label.Height = 70
label.Parent = form
form.ShowDialog()
您能否发布一些代码显示它在什么情况下失败?