私はコード作成の方法を学ぶ初心者で、Zed A Shaw(linkをPDFに書いた)の演習15、Study Drill#6に問題があります。それは述べている:私はPowerShellでのpythonを開いたときにPythonの難しい方法を学ぶエクササイズ15、Study Drill#6
Start python to start the python shell, and use open from the prompt just like in this program. Notice how you can open files and run read on them from within python?
私の問題がある(Pythonの2.7.11(v2.7.11:6d1b6a68f775、2015年12月5日夜08時32分19秒)[MSC v.1500 32ビット(インテル) ])、私はNotePad ++で保存したファイルを開くことができません。 PowershellでPythonで簡単なコードを実行できます。 C:\User\MyName\lpthw> python ex15.py samplefile.txt
を実行すると、エクササイズコードがうまく動作します。しかし、私はPowerShellでのpythonを起動し、
filename = "samplefile.txt"
txt = open(filename)
を実行したときに、私は
Traceback (most recent call last): File "", line 1, in IOError: [Errno 2] No such file or directory: 'samplefile.txt'.
エラーを取得するメモ帳++間違っているから、私の道ですか?私がNotePad ++で設定したパスは
*$(FULL_CONTENET_PATH)-C:\Program Files (x86)\Notepad++\$(FULL_CONTENT_PATH) (2.7.11)*
'filename =" C:\\ Program Files(x86)\\ ... "'バックスラッシュを倍にする必要があることに注意してください。 – zondo
投稿に書式を追加して誤植を取り除くことができると思いますか?それは少ししか読めません。 – TigerhawkT3
私はPDFへのリンクを追加しましたが、pdfのスタディドリルが#7であるため、使用しているものとは異なるバージョンの本のようです。 – Reti43