728x90
반응형

에러 메시지

  - SyntaxError: unexpected EOF while parsing

  - 특히 괄호 짝이 안맞을 경우 에러 메시지에서 어느 지점이 잘못 되었는지 정확히 보여주지 못할 때가 존재

1
2
3
4
  File "d:/14-ETC/VisualStudioCode/python/20200901_Test/main.py", line 79
 
                                       ^
SyntaxError: unexpected EOF while parsing
 
cs

 

해결 방법

  - 괄호 쌍, 따옴표 쌍 등 구문이 알맞게 적혀있는지 확인

 

  - 문제 발생 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import glob
import os
 
class PRACTICE:
 
    def __init__(self):
        return
 
    def Get_File_List1(self, path):
 
        FilePath = "FilePath!!"
        FileName = "FileName!!"
 
        return FilePath, FileName
 
path = "" 
instance = PRACTICE()
print(instance.Get_File_List1(path)     # 에러 발생 지점, 괄호가 하나 빠져있음
cs

 

  - 수정 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import glob
import os
 
class PRACTICE:
 
    def __init__(self):
        return
 
    def Get_File_List1(self, path):
 
        FilePath = "FilePath!!"
        FileName = "FileName!!"
 
        return FilePath, FileName
 
path = "" 
instance = PRACTICE()
print(instance.Get_File_List1(path))     # 괄호 쌍이 맞음
cs
728x90
반응형

+ Recent posts