19

cython を使用して helloworld.pyx から helloworld.c を作成すると、次のエラーが発生しました。

    error compiling Cython file:
------------------------------------------------------------
...
print('hello world',end='')
                      ^
------------------------------------------------------------

p21.pyx:1:23: Expected ')', found '='

helloworld.c を作成するコマンドは次のとおりです。

cython3 --embed p21.pyx
4

3 に答える 3

17

デフォルトでは、cython はすべてのプリントを python 2 ステートメントとして扱うようです。Python 3 の print 関数を使用するには、futureモジュールからインポートする必要があります。

from __future__ import print_function

print('hello world',end='')
于 2014-05-10T00:05:54.817 に答える