7

プログラミング初心者はこちら。Python IDLE で「pprint をインポート」しようとすると、次のエラーが発生します。

>>> import pprint
Traceback (most recent call last):
  File "<pyshell#21>", line 1, in <module>
    import pprint
  File "C:\Python34\pprint.py", line 10, in <module>
    pprint(count)
NameError: name 'pprint' is not defined

コマンドラインで「pip install pprint」を試みると思ったが、それもうまくいかなかった:

PS C:\Python34> pip install pprint
Collecting pprint
Could not find a version that satisfies the requirement pprint (from versions: )
No matching distribution found for pprint 

Python 3.4.3 には pprint モジュールが付属していると思っていました。どうすれば機能しますか?pprint をインポートできないようですが、他のすべてのモジュールは正常に動作しています。Automate The Boring Stuff with Python のいくつかの演習を完了するには、pprint モジュールが必要です。私の質問を見てくれてありがとう。

4

1 に答える 1

11

プログラムに名前を付けましたpprint。プログラムの名前を 以外の名前に変更し、存在する可能性のあるファイルをpprint.pyすべて削除します。pprint.pyc

于 2015-08-04T19:34:58.640 に答える