• <bdo id='puKIE'></bdo><ul id='puKIE'></ul>

      <i id='puKIE'><tr id='puKIE'><dt id='puKIE'><q id='puKIE'><span id='puKIE'><b id='puKIE'><form id='puKIE'><ins id='puKIE'></ins><ul id='puKIE'></ul><sub id='puKIE'></sub></form><legend id='puKIE'></legend><bdo id='puKIE'><pre id='puKIE'><center id='puKIE'></center></pre></bdo></b><th id='puKIE'></th></span></q></dt></tr></i><div id='puKIE'><tfoot id='puKIE'></tfoot><dl id='puKIE'><fieldset id='puKIE'></fieldset></dl></div>

      <small id='puKIE'></small><noframes id='puKIE'>

    1. <tfoot id='puKIE'></tfoot>
      <legend id='puKIE'><style id='puKIE'><dir id='puKIE'><q id='puKIE'></q></dir></style></legend>

      SyntaxError:解析时出现意外的 EOF

      时间:2024-04-20

      <i id='gUv08'><tr id='gUv08'><dt id='gUv08'><q id='gUv08'><span id='gUv08'><b id='gUv08'><form id='gUv08'><ins id='gUv08'></ins><ul id='gUv08'></ul><sub id='gUv08'></sub></form><legend id='gUv08'></legend><bdo id='gUv08'><pre id='gUv08'><center id='gUv08'></center></pre></bdo></b><th id='gUv08'></th></span></q></dt></tr></i><div id='gUv08'><tfoot id='gUv08'></tfoot><dl id='gUv08'><fieldset id='gUv08'></fieldset></dl></div>
        <tbody id='gUv08'></tbody>

        <small id='gUv08'></small><noframes id='gUv08'>

        • <tfoot id='gUv08'></tfoot>

          <legend id='gUv08'><style id='gUv08'><dir id='gUv08'><q id='gUv08'></q></dir></style></legend>

                <bdo id='gUv08'></bdo><ul id='gUv08'></ul>
              • 本文介绍了SyntaxError:解析时出现意外的 EOF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在运行这部分代码时遇到错误.我尝试了一些现有的解决方案,但都没有帮助.

                I am getting an error while running this part of the code. I tried some of the existing solutions, but none of them helped.

                elec_and_weather = pd.read_csv(r'C:HOUR.csv', parse_dates=True,index_col=0)
                # Add historic DEMAND to each X vector
                 for i in range(0,24):
                    elec_and_weather[i] = np.zeros(len(elec_and_weather['DEMAND']))
                    elec_and_weather[i][elec_and_weather.index.hour==i] = 1
                # Set number of hours prediction is in advance
                n_hours_advance = 24
                
                # Set number of historic hours used
                n_hours_window = 24
                
                for k in range(n_hours_advance,n_hours_advance+n_hours_window):
                    elec_and_weather['DEMAND_t-%i'% k] = np.zeros(len(elec_and_weather['DEMAND']))'
                

                我总是收到这个错误:

                for i in range(0,24):
                File "<ipython-input-29-db3022a769d1>", line 1
                for i in range(0,24):
                                     ^
                SyntaxError: unexpected EOF while parsing
                
                File "<ipython-input-25-df0a44131c36>", line 1
                    for k in range(n_hours_advance,n_hours_advance+n_hours_window):
                                                                                   ^
                SyntaxError: unexpected EOF while parsing
                

                推荐答案

                SyntaxError: unexpected EOF while parsing 表示在所有代码块完成之前就到达了源代码的末尾.代码块以 for i in range(100): 之类的语句开头,之后至少需要一行包含应在其中的代码.

                The SyntaxError: unexpected EOF while parsing means that the end of your source code was reached before all code blocks were completed. A code block starts with a statement like for i in range(100): and requires at least one line afterwards that contains code that should be in it.

                您似乎是在 ipython 控制台中逐行执行程序.这适用于像 a = 3 这样的单个语句,但不适用于像 for 循环这样的代码块.请参阅以下示例:

                It seems like you were executing your program line by line in the ipython console. This works for single statements like a = 3 but not for code blocks like for loops. See the following example:

                In [1]: for i in range(100):
                  File "<ipython-input-1-ece1e5c2587f>", line 1
                    for i in range(100):
                                        ^
                SyntaxError: unexpected EOF while parsing
                

                为避免此错误,您必须将整个代码块作为单个输入输入:

                To avoid this error, you have to enter the whole code block as a single input:

                In [2]: for i in range(5):
                   ...:     print(i, end=', ')
                0, 1, 2, 3, 4,
                

                这篇关于SyntaxError:解析时出现意外的 EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:TypeError:“dict_keys"对象不支持索引 下一篇:设置计划的工作?

                相关文章

                <i id='kJBkG'><tr id='kJBkG'><dt id='kJBkG'><q id='kJBkG'><span id='kJBkG'><b id='kJBkG'><form id='kJBkG'><ins id='kJBkG'></ins><ul id='kJBkG'></ul><sub id='kJBkG'></sub></form><legend id='kJBkG'></legend><bdo id='kJBkG'><pre id='kJBkG'><center id='kJBkG'></center></pre></bdo></b><th id='kJBkG'></th></span></q></dt></tr></i><div id='kJBkG'><tfoot id='kJBkG'></tfoot><dl id='kJBkG'><fieldset id='kJBkG'></fieldset></dl></div>
                • <bdo id='kJBkG'></bdo><ul id='kJBkG'></ul>

                1. <legend id='kJBkG'><style id='kJBkG'><dir id='kJBkG'><q id='kJBkG'></q></dir></style></legend>

                  <small id='kJBkG'></small><noframes id='kJBkG'>

                    <tfoot id='kJBkG'></tfoot>