2017-01-21 50 views
0

我正在使用Eclipse Mars 2,Pydev 5.1.2,Python 3.5。我寫了一個簡單的代碼去傳遞列表的數量(可變num),並打印出每個後續輸入的整數列表:Pydev調試器提供輸入後拋出語法錯誤

num=int(input()) #taking the no of lists to be inputted 
n=[]    #stores the elements in each list 

for i in range(0,num): #iterating over the test cases 
    n = [int(x) for x in input().split()] 
    print("n: ",n) 

我把一個斷點在for循環。當我調試程序,進入「名單號碼」後,當我進入榜單的實際元素,並按「Enter」,我得到一個語法錯誤,具體如下:

enter image description here

enter image description here

程序執行正常。我只在調試時遇到此錯誤。

請幫我理解這個原因。

:控制檯輸出,如邁克爾要求:

pydev debugger: starting (pid: 4172) 
2 
2 1 
Traceback (most recent call last): 
    File "E:\software\dev tools\eclipse\eclipse-jee-neon-2-win32\dropins\plugins\org.python.pydev_5.5.0.201701191708\pysrc\_pydevd_bundle\pydevd_vars.py", line 354, in evaluate_expression 
    compiled = compile(expression, '<string>', 'eval') 
    File "<string>", line 1 
    2 1 
    ^
SyntaxError: invalid syntax 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "E:\software\dev tools\eclipse\eclipse-jee-neon-2-win32\dropins\plugins\org.python.pydev_5.5.0.201701191708\pysrc\_pydevd_bundle\pydevd_comm.py", line 1122, in do_it 
    result = pydevd_vars.evaluate_expression(self.thread_id, self.frame_id, self.expression, self.doExec) 
    File "E:\software\dev tools\eclipse\eclipse-jee-neon-2-win32\dropins\plugins\org.python.pydev_5.5.0.201701191708\pysrc\_pydevd_bundle\pydevd_vars.py", line 356, in evaluate_expression 
    Exec(expression, updated_globals, frame.f_locals) 
    File "E:\software\dev tools\eclipse\eclipse-jee-neon-2-win32\dropins\plugins\org.python.pydev_5.5.0.201701191708\pysrc\_pydevd_bundle\pydevd_exec2.py", line 3, in Exec 
    exec(exp, global_vars, local_vars) 
    File "<string>", line 1 
    2 1 
    ^
SyntaxError: invalid syntax 
+0

您可以將第一個錯誤粘貼爲文本,以便於查看。 – Michael

+0

我仍然無法理解此錯誤的原因。任何人都可以提供任何線索嗎?它已近2個月了.... –

回答

0

請升級到最新版本。

這已在5.4.0中修復。

從發行說明(從http://www.pydev.org/history_pydev.html拍攝):

調試:當用戶正在等待某些輸入時,將不再嘗試評估輸入的內容。

+0

我更新了Eclipse Neon 2(4.6.2),Pydev 5.5.0,Python 3.6。但我仍然面臨同樣的問題。 –