Skip to content

Commit 87f2d2a

Browse files
authored
Update README.rst
1 parent f544adc commit 87f2d2a

File tree

1 file changed

+21
-28
lines changed

1 file changed

+21
-28
lines changed

README.rst

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,43 @@ pythonnet - Python for .NET
88
|license shield| |pypi package version| |python supported shield|
99
|stackexchange shield|
1010

11-
Python for .NET is a package that gives Python programmers nearly
12-
seamless integration with the .NET Common Language Runtime (CLR) and
13-
provides a powerful application scripting tool for .NET developers. It
14-
allows Python code to interact with the CLR, and may also be used to
15-
embed Python into a .NET application.
11+
Python for .NET 是一个包,可以让 Python 程序员几乎无缝集成 .NET 公共语言
12+
运行时 (CLR),并为 .NET 开发者提供一个功能强大的应用程序脚本工具。它允许
13+
Python 代码与 CLR 交互,也可以用于将 Python 嵌入到 .NET 应用程序中。
1614

17-
Calling .NET code from Python
15+
在 Python 中调用 .NET 代码
1816
-----------------------------
1917

20-
Python for .NET allows CLR namespaces to be treated essentially as
21-
Python packages.
18+
Python for .NET 允许将 CLR 命名空间当作真正的 Python 包。
2219

2320
.. code-block::
2421
2522
import clr
2623
from System import String
2724
from System.Collections import *
2825
29-
To load an assembly, use the ``AddReference`` function in the ``clr``
30-
module:
26+
要加载程序集,请使用 ``clr`` 模块中的 ``AddReference`` 函数:
3127

3228
.. code-block::
3329
3430
import clr
3531
clr.AddReference("System.Windows.Forms")
3632
from System.Windows.Forms import Form
3733
38-
Embedding Python in .NET
34+
.NET 中嵌入 Python
3935
------------------------
4036

41-
- All calls to python should be inside a
42-
``using (Py.GIL()) {/* Your code here */}`` block.
43-
- Import python modules using ``dynamic mod = Py.Import("mod")``, then
44-
you can call functions as normal, eg ``mod.func(args)``.
45-
- Use ``mod.func(args, Py.kw("keywordargname", keywordargvalue))`` or
46-
``mod.func(args, keywordargname: keywordargvalue)`` to apply keyword
47-
arguments.
48-
- All python objects should be declared as ``dynamic`` type.
49-
- Mathematical operations involving python and literal/managed types
50-
must have the python object first, eg. ``np.pi * 2`` works,
51-
``2 * np.pi`` doesn't.
52-
53-
Example
37+
- 所有对 python 的调用应该被包含在一个
38+
``using (Py.GIL()) {/* Your code here */}`` 块中。
39+
- 使用 ``dynamic mod = Py.Import("mod")`` 导入 python 模块,然后你就可以
40+
像平常一样调用函数,例如 ``mod.func(args)``。
41+
- 使用 ``mod.func(args, Py.kw("keywordargname", keywordargvalue))`` 或
42+
``mod.func(args, keywordargname: keywordargvalue)`` 来应用关键字参数。
43+
- 所有 python 对象都应该被声明为 ``dynamic`` 类型。
44+
- 涉及 python 和字面值/托管类型的数学操作必须先使用 python 对象,例如,
45+
``np.pi * 2`` 有效,``2 * np.pi`` 不行。
46+
47+
示例
5448
~~~~~~~
5549

5650
.. code-block:: csharp
@@ -79,7 +73,7 @@ Example
7973
}
8074
}
8175
82-
Output:
76+
输出:
8377

8478
.. code::
8579
@@ -90,10 +84,9 @@ Output:
9084
int32
9185
[ 6. 10. 12.]
9286
93-
Information on installation, FAQ, troubleshooting, debugging, and
94-
projects using pythonnet can be found in the Wiki:
87+
关于安装、常见问题、故障排除、调试和使用 pythonnet 项目的信息,可以在 Wiki 中找到:
9588

96-
https://github.com/pythonnet/pythonnet/wiki
89+
https://github.com/lidanger/pythonnet/wiki
9790

9891
.. |Join the chat at https://gitter.im/pythonnet/pythonnet| image:: https://badges.gitter.im/pythonnet/pythonnet.svg
9992
:target: https://gitter.im/pythonnet/pythonnet?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

0 commit comments

Comments
 (0)