WEB开发网
开发学院软件开发Python 用Iron-*语言来探索.NET 阅读

用Iron-*语言来探索.NET

 2010-09-22 11:26:54 来源:WEB开发网   
核心提示:刚才写代码的时候又是在不停查文档,甚是心烦,用Iron-*语言来探索.NET,一怒,拿出IronPython

刚才写代码的时候又是在不停查文档,甚是心烦。一怒,拿出IronPython,类似这样:

Ipy 2.6 beta代码  

IronPython 2.6 Beta DEBUG (2.6.0.1) on .NET 2.0.50727.3082
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> clr.AddReference('System')
>>> import System
>>> System
<module 'System' (CLS module, 2 assemblies loaded)>
>>> R = System.Text.RegularExpressions.Regex
>>> r = R('abc')
>>> s = '123abcd456'
>>> dir(r)
['CacheSize', 'CompileToAssembly', 'Equals', 'Escape', 'GetGroupNames', 'GetGroupNumbers', 'GetHashCode', 'GetObjectData', 'GetType', 'GroupNameFromNumber', 'GroupNumberFromName', 'InitializeReferences', 'IsMatch', 'Match', 'Matches', 'MemberwiseClone', 'Options', 'ReferenceEquals', 'Replace', 'RightToLeft', 'Split', 'ToString', 'Unescape', 'UseOptionC', 'UseOptionR', '__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__subclasshook__', 'capnames', 'caps', 'capsize', 'capslist', 'factory', 'pattern', 'roptions']
>>> m = r.Match(s)
>>> dir(m)
['Captures', 'Empty', 'Equals', 'GetHashCode', 'GetType', 'Groups', 'Index', 'Length', 'MemberwiseClone', 'NextMatch', 'ReferenceEquals', 'Result', 'Success', 'Synchronized', 'ToString', 'Value', '__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__subclasshook__']
>>> m.Success
True
>>> m.Index
3
>>> m.ToString()
'abc'
>>>

1 2  下一页

Tags:Iron 探索

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接