我有一个python方法返回一个Python字节array.array('c').
现在,我想使用System.Runtime.InteropServices.Marshal.Copy复制此数组.但是,此方法需要.NET数组.
import array
from System.Runtime.InteropServices import Marshal
bytes = array.array('c')
bytes.append('a')
bytes.append('b')
bytes.append('c')
Marshal.Copy(bytes, dest, 0, 3)
Run Code Online (Sandbox Code Playgroud)
有没有办法在不复制数据的情况下完成这项工作?如果没有,我如何将Python数组中的数据转换为.NET数组?
在Cpython中,我可以使用win32com.
但是,在ironpython中,我不知道如何导入它.
因为,在.net中,总是使用Visual Studio来交互COM并使用它.
这可能是一个奇怪的问题,但有没有可靠的方法来序列化类扩展CLR类型的IronPython对象?
例如:
class Foo(System.Collections.Generic.List[str]):
def Test(self):
print "test!"
Run Code Online (Sandbox Code Playgroud)
System.Collections.Generic.List<string>可以使用Pickle进行序列化,因为它实现了ISerializable接口,但是可序列化CLR类型的发出子类似乎不起作用,而且我ImportError: No module named Generic in mscorlib, Version=4在运行时得到pickle.dumps(Foo()).
此外,运行通常Formatter.Serialize(stream, object)给我:
SystemError: Type 'IronPython.NewTypes.System.Collections.Generic.List`1_4$4' in Assembly Snippets.scripting, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
Run Code Online (Sandbox Code Playgroud)
在嵌入式C#环境中运行时,如何实现IronPython对象的序列化?
当使用IronPython托管时,__name__特殊变量将返回<module>而不是__main__.我在这里找到了一些讨论:http://lists.ironpython.com/pipermail/users-ironpython.com/2006-August/003274.html.但我不知道如何将它应用于我的代码:
public static void RunPythonFile(string filename)
{
// This is the Key to making sure that Visual Studio can debug
// the Python script. This way you can attach to 3dsMax.exe
// and catch exceptions that occur right at the correct location
// in the Python script.
var options = new Dictionary<string, object>();
options["Debug"] = true;
// Create an instance of the Python run-time
var runtime = Python.CreateRuntime(options);
// Retrive …Run Code Online (Sandbox Code Playgroud) 我想学习python所以我从python站点下载它,我看到其他4种蟒蛇出现:
我真的可以找到它们之间的差异.还有哪一个是最好的开始.
我有一个C#.NET类,它存在于需要在IronPython中访问的命名空间之外.通常我会这样做:
import SomeNamespace
from SomeNamespace import *
Run Code Online (Sandbox Code Playgroud)
但是,我没有命名空间.
我正在使用IronPython,我想创建一些窗体,我想创建一个带有一些按钮的窗体,我想在视觉工作室用铁蟒这样做,我正在使用visual studio 2012集成版,每次我创建了一个"ironpython windows form"项目,当我想运行它时,它说:
该项目目前设置为使用.NET调试器进行IronPython调试,但该项目配置为从CPython解释器开始.要在项目属性 - >调试 - >启动模式下修改此更改调试器类型
当我将调试器更改为Standard Python Launcher时,它说:
ImportError:没有名为clr的模块
我该怎么办?
我刚刚获得了带有PTVS的Visual Studio 2013 RC(用于Visual Studio的Python工具).我如何使用Visual Studio内置的Windows窗体设计器?VS有一个用于WF的Iron Python模板,但没有办法使用实际的GUI设计器.有没有办法通过python获得GUI设计器功能?
我正在尝试使用pycharm来调试ironpython脚本.它很糟糕,因为pycharm在调试模式下运行得非常慢.我意识到我们可以预期会有一些放缓,但我正在经历大约200倍的放缓.以下是我的pystone结果:
正常运行:
"C:\Program Files (x86)\IronPython 2.7\ipy.exe" C:/Users/melchoir55/PycharmProjects/pystone/pystone.py
Pystone(1.1) time for 50000 passes = 0.270744
This machine benchmarks at 184676 pystones/second
Run Code Online (Sandbox Code Playgroud)
调试器:
"C:\Program Files (x86)\IronPython 2.7\ipy.exe" -X:Frames "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 3.0.1\helpers\pydev\pydevd.py" --multiproc --client 127.0.0.1 --port 52669 --file C:/Users/melchoir55/PycharmProjects/pystone/pystone.py
pydev debugger: warning: sys._current_frames is not supported in Python 2.4, it is recommended to install threadframe module
pydev debugger: warning: See http://majid.info/blog/threadframe-multithreaded-stack-frame-extraction-for-python/
pydev debugger: process 9064 is connecting
Connected to pydev debugger (build 131.339)
Pystone(1.1) time for 50000 passes = 71.5615 …Run Code Online (Sandbox Code Playgroud) 我在Spotfire中有一个列表框,里面有国家/地区。列表框包括(无)作为选择选项。当在列表框中选择一个国家时,该国家的名称和一个星形图标将出现在另一个测试面板中。此后,如果选择(无),则国家的名称消失,而星星仅淡出。我需要像文本一样消失。
这是一个例子:
这是面板中用于输出的javascript。如果未选择,则不显示图标。
$("#b67963fdb4724d11b744affb05048a23").on('change',function(){
$("#b67963fdb4724d11b744affb05048a23 option:selected").text()=="None"?
document.getElementById($("#9bf3680df22140b9955b39c8ba6cfff8")).style.display = "hidden" :
document.getElementById($("#9bf3680df22140b9955b39c8ba6cfff8")).style.display = "visible"
})Run Code Online (Sandbox Code Playgroud)
这是图标属性:
如果未选择任何国家,如何使图标消失?
ironpython ×10
python ×7
.net ×3
c# ×3
arrays ×1
clr ×1
com ×1
debugging ×1
javascript ×1
jython ×1
marshalling ×1
namespaces ×1
performance ×1
pickle ×1
ptvs ×1
pycharm ×1
pypy ×1
scripting ×1
spotfire ×1
tibco ×1