The python print() will only print its arguments like a tuple after this .py is CPython-compiled into a .so and being imported.
(将这个.py CPython编译成.so并导入后,python print()只会像元组一样打印其参数。)
How can it behave like it is a normal py file? (它如何表现得像普通的py文件?)
The scenarios is like this.
(场景是这样的。)
Here is a function output()
defined in mod4.py: (这是在mod4.py中定义的函数output()
:)
def output(a, b):
print(a, b, str(a)+str(b))
I use following code to call output()
:
(我使用以下代码来调用output()
:)
import mod4
mod4.output(2, 3)
the output will be like:
(输出将是这样的:)
2 3 23
However, if I use CPython to compile mod4.py into mod4.cpython-37m-darwin.so, and the code above will generate output like:
(但是,如果我使用CPython将mod4.py编??译为mod4.cpython-37m-darwin.so,则上面的代码将生成如下输出:)
(2, 3, '23')
it looks just like a tuple of the arguments of print().
(它看起来就像是print()参数的元组。)
How can I get output()
in .so outputs just like it in .py?
(如何在.so输出中获得与.py一样的output()
?)
ask by Cuteufo translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…