[解決済み] トークン・エラーです。複数行のステートメントでEOF
2022-02-01 20:36:23
質問
以下のコードでこのエラーが発生しました "トークンエラー。EOF in multi-line statement" と表示されます。このエラーは何ですか?どうすれば直せますか?
import easygui
import time
namegui = easygui.enterbox(msg='Enter your name:', title='Name query', default='Gian')
situationgui = easygui.enterbox(msg='Please enter your situation:', title='Thought Log(Situation)')
thoughtsgui = easygui.enterbox(msg='Please enter your thoughts:', title='Thought Log(Thoughts')
emotionsgui = easygui.enterbox(msg='Please enter your emotions: \n Sad, Mad, Hurt, Depressed, Anxious, Tense, etc.', title='Thought Log(Emotions')
behaviorgui = easygui.enterbox(msg='Please enter your behavior:', title='Thought Log(Behavior')
thinking_trapsgui = easygui.enterbox(msg='Please identify your thinking traps: \n \n'
'FORTUNE-TELLING: This occurs when we predict that things will turn out badly. However, we cannot predict the future because we do not have a magic ball! \n \n'
'MIND-READING: This happens when we believe that we know what others are thinking and we assume that they are thinking the worst of us. However, we cannot mind-read so we do not know what others are thinking! \n \n'
'LABELING: Sometimes we talk to ourselves in a mean way and we use a single negative word to describe ourselves. However, this kind of thinking is unfair and we are too complex to be summed up in a single word! \n \n'
'FILTERING: This happens when we take note of all the bad things that happen, but ignore any good things. \n \n'
'OVERESTIMATING: This happens when we believe that something that is unlikely to occur is actually about to happen. \n \n'
'CATASTROPHIZING: This is when we imagine the worst possible thing is about to happen and we will be unable to cope with it. \n \n'
'OVERGENERALIZING: This is when we use words like always or never to describe situations or events. This is a problematic way of thinking because it does not take all situation or events into account \n \n',
title='Thought Log(Identify Your Thinking Traps)')
BAI_var = easygui.choicebox(
msg='Please identify your thinking traps: \n \n',
title='Thought Log(Identify Your Thinking Traps)',
choices=('FORTUNE-TELLING: This occurs when we predict that things will turn out badly. However, we cannot predict the future because we do not have a magic ball! \n \n
'MIND-READING: This happens when we believe that we know what others are thinking and we assume that they are thinking the worst of us. However, we cannot mind-read so we do not know what others are thinking! \n \n'
'LABELING: Sometimes we talk to ourselves in a mean way and we use a single negative word to describe ourselves. However, this kind of thinking is unfair and we are too complex to be summed up in a single word! \n \n'
'FILTERING: This happens when we take note of all the bad things that happen, but ignore any good things. \n \n'
'OVERESTIMATING: This happens when we believe that something that is unlikely to occur is actually about to happen. \n \n'
'CATASTROPHIZING: This is when we imagine the worst possible thing is about to happen and we will be unable to cope with it. \n \n'
'OVERGENERALIZING: This is when we use words like always or never to describe situations or events. This is a problematic way of thinking because it does not take all situation or events into account \n \n')
alt_behaviorgui = easygui.enterbox(msg='Please enter alternative behavior:', title='Thought Log(Alt Behavior)')
alt_thoughtsgui = easygui.enterbox(msg='Please enter alternative thoughts:', title='Thought Log(Alt Thoughts)')
yeargui = easygui.enterbox(msg='Enter the current year:', title='Current Year', default='2011')
monthgui = easygui.enterbox(msg='Enter the current month:', title='Current Month')
daygui = easygui.enterbox(msg='Enter the current day:', title='Current Day')
time_hourgui = easygui.enterbox(msg='Enter the current hour:', title='Current Hour')
time_minutegui = easygui.enterbox(msg='Please enter current minutes:', title='Current Minute')
am_pmgui = easygui.enterbox(msg='Please enter either am or pm:', title='AM OR PM')
file = open('Thought Record 1.0.txt', 'a')
file.write(namegui + '\n')
file.write(daygui)
file.write('/')
file.write(monthgui)
file.write('/')
file.write(yeargui)
file.write('\n')
file.write('Your situation:')
file.write(situationgui)
file.write('\n')
file.write('Your thoughts:')
file.write(thoughtsgui)
file.write('\n')
file.write('Your emotions:')
file.write(emotionsgui)
file.write('\n')
file.write('Your behavior:')
file.write(behaviorgui)
file.write('\n')
file.write('Thinking traps:')
file.write(thinking_trapsgui)
file.write('\n')
file.write('Alternative bahvior:')
file.write(alt_behaviorgui)
file.write('\n')
file.write('Alternative thoughts:')
file.write(alt_thoughtsgui)
file.write('\n')
file.write('\n')
file.close()
このエラーは、次のコードの行を追加した後にのみ表示されました。
BAI_var = easygui.choicebox(
msg='Please identify your thinking traps: \n \n',
title='Thought Log(Identify Your Thinking Traps)',
choices=('FORTUNE-TELLING: This occurs when we predict that things will turn out badly. However, we cannot predict the future because we do not have a magic ball! \n \n
'MIND-READING: This happens when we believe that we know what others are thinking and we assume that they are thinking the worst of us. However, we cannot mind-read so we do not know what others are thinking! \n \n'
'LABELING: Sometimes we talk to ourselves in a mean way and we use a single negative word to describe ourselves. However, this kind of thinking is unfair and we are too complex to be summed up in a single word! \n \n'
'FILTERING: This happens when we take note of all the bad things that happen, but ignore any good things. \n \n'
'OVERESTIMATING: This happens when we believe that something that is unlikely to occur is actually about to happen. \n \n'
'CATASTROPHIZING: This is when we imagine the worst possible thing is about to happen and we will be unable to cope with it. \n \n'
'OVERGENERALIZING: This is when we use words like always or never to describe situations or events. This is a problematic way of thinking because it does not take all situation or events into account \n \n')
Mac OS X 10.6でPython 2.5を動かしています。
解決方法を教えてください。
選択肢の変数の最初の行にアポストロフィがない(
'
) を最後につけてください。
関連
-
PythonによるExcelファイルの一括操作の説明
-
Python LeNetネットワークの説明とpytorchでの実装
-
[解決済み】ilocが「IndexError: single positional indexer is out-of-bounds」を出す。
-
[解決済み] データ型が理解できない
-
[解決済み】fatal error: Python.h: そのようなファイルやディレクトリはありません
-
[解決済み] 複数の例外を1行でキャッチする(ブロックを除く)
-
[解決済み] Pythonのswitch文の代用品?
-
[解決済み] 複数行の長い文字列を作成するためのPythonicな方法
-
[解決済み] Pythonで改行(行継続)をするにはどうしたらいいですか?
-
[解決済み] ファイルに行を書き込む正しい方法?
最新
-
nginxです。[emerg] 0.0.0.0:80 への bind() に失敗しました (98: アドレスは既に使用中です)
-
htmlページでギリシャ文字を使うには
-
ピュアhtml+cssでの要素読み込み効果
-
純粋なhtml + cssで五輪を実現するサンプルコード
-
ナビゲーションバー・ドロップダウンメニューのHTML+CSSサンプルコード
-
タイピング効果を実現するピュアhtml+css
-
htmlの選択ボックスのプレースホルダー作成に関する質問
-
html css3 伸縮しない 画像表示効果
-
トップナビゲーションバーメニュー作成用HTML+CSS
-
html+css 実装 サイバーパンク風ボタン
おすすめ
-
python call matlab メソッドの詳細
-
Python 人工知能 人間学習 描画 機械学習モデル作成
-
Python interpreted model libraryによる機械学習モデル出力の可視化 Shap
-
[解決済み] _tkinter.TclError: 表示名がなく、$DISPLAY環境変数もない。
-
[解決済み】TypeErrorの修正方法。Unicodeオブジェクトは、ハッシュ化する前にエンコードする必要がある?
-
[解決済み】numpy: true_divide で無効な値に遭遇
-
[解決済み】csv.Error:イテレータはバイトではなく文字列を返すべき
-
[解決済み】インポートエラー。モジュール名 urllib2 がない
-
[解決済み】ImportError: bs4という名前のモジュールがない(BeautifulSoup)
-
[解決済み】 TypeError: += でサポートされていないオペランド型: 'int' および 'list' です。