The str function in ironpython2.7 does not support Chinese variables.

Source: Internet
Author: User

 

I want to say:
In fact, ironpython2.7 provides excellent support for Chinese characters.
You can rest assured to use
But remember not to use the str () function.
It cannot be parsed if it contains Chinese characters.
I checked a lot of information.
You have to change the source code.
The above uses SharpDeverlop + Iconpython2.7 for testing.

 

 

 

The window is pulled by the SharpDeverlop ipy designer.

Rough source code

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. createlist ()
Print 'Load parser'
# 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)
Failed t RunAlt. MyError as e:
Print 'my exception, value: ', e. value

RunAlt = RunAlt ("print 'call '")
RunAlt. RunPy ()
From System import Console
Console. Read ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.