使用IronPython从C#运行Python脚本

时间:2018-11-21 20:38:20

标签: c# python ironpython

虽然我尝试使用Iron Python从C#运行python代码,但在尝试用C#编写代码时遇到了一些异常,但是它没有任何改变。还有其他选项可以在C#中运行python代码吗?还是我的代码有问题?在python中,一切正常,直到我从C#运行它为止。

Select *
From XMLTABLE ('nodeName',
    XmlType('<nodeName>)
         Columns — that 1 value);

我在Python中有这个文件

private static string GetBitcoinPrivateKeyFromMnemonic(string mnemonic)
{
var engine = Python.CreateEngine();
ICollection<string> paths = engine.GetSearchPaths();
var dir1 = @"/home/hackslash/.local/lib/python3.7/site-packages";
var dir2 = @"/usr/lib/python3.7";
paths.Add(dir1);
paths.Add(dir2);
engine.SetSearchPaths(paths);
dynamic py = engine.ExecuteFile(@"/home/hackslash/Magnify/MagnifyDevelopment/Python/bitcoin.py");
dynamic bitcoin = py.Bitcoin();
var bitcoinPrivateWIF = bitcoin.generate_bitcoin_private_wif(mnemonic);
return bitcoinPrivateWIF;
}

我收到此异常: from btctools import * import hashlib class Bitcoin: @classmethod def generate_bitcoin_address_from_wif(cls, private_key_wif): private_key = PrivateKey.from_wif(private_key_wif) public_key = private_key.to_public() public_address = public_key.to_address('P2PKH', compressed=False) return public_address @classmethod def generate_bitcoin_private_wif(cls, mnemonic): hashed_words = hashlib.sha256(mnemonic.encode()).hexdigest() private_key = PrivateKey.from_hex(hashed_words) private_wif = private_key.wif(compressed=False) return private_wif

0 个答案:

没有答案