0
ファイル位置のDataFrameを反復処理しています。私が望むファイルを見つけたら、解凍して名前を変更しようとします。それが失敗すると、私はデータフレームの次の行に進みます。問題は、私が "continue"を呼び出すと、メインのforループにジャンプする代わりに、以前のforループにジャンプしてプログラムがハングするということです。エラーの場合にどのループをフォールバックするかを指定する方法はありますか?データフレームからデータを読み込もうとするとPythonがハングアップする
がfor index, row in df.iterrows(): #if something fails I want to go back here
#get the file location
for file in location: #"continue" is taking me back to here which I don't want
#search for file
if file found:
file_found = True
if not file_found:
continue
else:
file_found = False
try:
#unzip file
except:
#could not unzip
continue
try:
#rename unzipped file
except:
try:
#try renaming a different way
except:
#could not rename file
continue
「break」文はどうですか? [docs](https://docs.python.org/2/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops)から: "break文は次のようになります。 C、最内周のforループまたはwhileループから外れます。 – davedwards
提案していただきありがとうございます。私はPythonが外側forループの代わりに以前のものと同じ問題を実行するという点で同じ問題を抱えています。 – sparrow
Hm、okコードを使用して結果を再現しようとします – davedwards