我想说:
其实ironpython2.7对中文支持的挺好
大家可以放心使用
但切记str()这个函数就不要用
如果里面有中文就无法解析
查了很多资料
都要动手改源代码了
以上使用 SharpDeverlop+Iconpython2.7测试
其实ironpython2.7对中文支持的挺好
大家可以放心使用
但切记str()这个函数就不要用
如果里面有中文就无法解析
查了很多资料
都要动手改源代码了
以上使用 SharpDeverlop+Iconpython2.7测试
窗口是用SharpDeverlop的ipy设计器拉的。
大致的源码
class MyError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class RunAlt():
import clr
clr.AddReference( ' IronPython ')
from IronPython.Hosting import Python
engine = Python.CreateEngine()
scope = engine.CreateScope()
print ' 加载解析器 '
# scope.SetVariable("my_object_model", CallingPython())
def __init__(self,str):
self.Str=str
def GetPy(self):
return self.Str
def RunPy(self):
# self.engine.Execute("print ''")
try:
source = self.engine.CreateScriptSourceFromString(self.Str)
source.Execute(self.scope)
except RunAlt.MyError as e:
print ' My exception, value: ', e.value
runAlt=RunAlt( " print '调用' ")
runAlt.RunPy()
from System import Console
Console.Read()
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class RunAlt():
import clr
clr.AddReference( ' IronPython ')
from IronPython.Hosting import Python
engine = Python.CreateEngine()
scope = engine.CreateScope()
print ' 加载解析器 '
# scope.SetVariable("my_object_model", CallingPython())
def __init__(self,str):
self.Str=str
def GetPy(self):
return self.Str
def RunPy(self):
# self.engine.Execute("print ''")
try:
source = self.engine.CreateScriptSourceFromString(self.Str)
source.Execute(self.scope)
except RunAlt.MyError as e:
print ' My exception, value: ', e.value
runAlt=RunAlt( " print '调用' ")
runAlt.RunPy()
from System import Console
Console.Read()