另一个令牌错误:多行语句中的 EOF
以下代码给出了此错误“令牌错误:多行语句中的 EOF”。但我似乎找不到错误!也许其他人会看到它?
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)')
thinking_trapsgui = 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()
此外,错误总是突出显示 file.close()
之后的最后一行。我不明白为什么?
我在 Mac OS X 10.6 上运行 Python 2.5
The following code gives me this error "Token Error: EOF in multi-line statement". I cannot seem to find the error though! Maybe someone else will see it?
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)')
thinking_trapsgui = 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()
Also the error always highlights the last line after file.close()
. I do not understand why?
I am running Python 2.5 on Mac OS X 10.6
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您缺少变量 Thinking_trapsgui 的结束 ) 。检查这是否是问题所在。
缺少 ) 通常会给出语法错误,所以我不太确定,但 EOF 多行令牌错误可能指向这一点。
编辑
你已经写了
上面的最后一个“)”是用于 chioces 参数。因此,只需在上一行的末尾添加另一个“)”即可。
You are missing a closing ) for variable thinking_trapsgui. Check if thats the problem.
A missing ) usually gives a Syntax Error so I am not really sure, but EOF multi-line Token Error could be pointing to that.
EDIT
You have written
The last ')' above is for chioces argument. So just add another ')' at the end of the above line.