OTHER·중요도 5·2026. 08. 07.·GeekNews

Python 문자열 리터럴의 예상 밖 구문 규칙

── KO ──────────────────

파이썬의 raw 문자열 리터럴 구문 규칙에 대한 설명.

파이썬의 raw 문자열 리터럴은 일반 문자열처럼 어휘 분석되며, 끝에 홀수 개의 백슬래시를 사용할 수 없습니다. 예를 들어, 'r'asdf\''는 문법 오류를 발생시키지만, 'r'asdf\''는 유효한 문자열로 인식됩니다. 이러한 규칙은 문자열 리터럴 사용 시 주의가 필요합니다.


── EN ──────────────────

Explanation of syntax rules for Python raw string literals.

Python raw string literals are lexically analyzed like regular strings and cannot end with an odd number of backslashes. For instance, 'r'asdf\'' will cause a syntax error, while 'r'asdf\'' is valid. This rule necessitates caution when using string literals.

원문 보기 →목록으로