擅长:python、mysql、java
<p>如果您想实现另一个程序来精确复制CPython解释器的当前行为,可以研究复数表示的源代码:<a href="https://github.com/python/cpython/blob/9b6c60cbce4ac45e8ccd7934babff465e9769509/Objects/complexobject.c#L352" rel="nofollow noreferrer">^{<cd1>}</a>。此函数负责将复数转换为字符串。在</p>
<p>一些血腥的细节可以在函数<a href="https://github.com/python/cpython/blob/e2f92de6a90ae11a6d8e01bd17fd88b005516835/Python/pystrtod.c#L792" rel="nofollow noreferrer">^{<cd2>}</a>中找到。在</p>
<p>我不认为浮点数的确切交互输出是官方Python语言规范的一部分,因此源代码可能是这里最好的指南。在</p>
<hr/>
<p>编辑:如果你不想重新发明轮子,那可能是时候研究一下<a href="https://docs.python.org/3.6/extending/embedding.html" rel="nofollow noreferrer">embedding Python in another application</a>。在</p>