• 회원가입
  • 로그인
  • 구글아이디로 로그인

[function] Python - locals() 함수 - 지역 심볼 테이블을 dictionary 형태로 반환. (= locals함수 = 로컬즈함수)

1151  
locals() 예제 - local symbol table 표시

 

x = locals()

print(x)

 

결과값:

{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, '__file__': 'C:\\Users\\사용자명\\AppData\\Local\\Programs\\Python\\Python39\\test.py', 'x': {...}}

 

locals() 정의

 

local symbol table 을 dictionary 형태로 반환.

※ symbol table : 현재 프로그램에 대한 필요한 정보가 담김.

 


cf.

globals() 함수 : 전역 기호 테이블을 dictionary 형태로 반환.

 

 

locals() 구문

 

locals()

 


[매개변수]

 

없음.

 

 

locals() 예제

 

x = locals()

print(x["__file__"])

 

결과값:

C:\Users\사용자명\AppData\Local\Programs\Python\Python39\test.py

 


분류 제목
string Python - capitalize() 메서드 - 문자열의 첫글자만 대문자로 변환. (= capitalize…
string Python - casefold() 메서드 - 모든 문자열을 소문자로 변환. (= casefold메서드 = …
string Python - center() 메서드 - 지정 문자로 문자열 가운데 정렬. (= 센터)
string Python - count() 메서드 ★★ - 지정 문자열 포함 횟수. (= 카운트)
string Python - encode() 메서드 ★★ - 지정 인코딩 방식으로 문자열 인코딩. (= encode메서드…
string Python - endswith() 메서드 - 문자열이 지정 문자열로 끝나는지 체크. (= endswith메…
string Python - expandtabs() 메서드 - 문자열 내 Tab 간격 지정. (= 익스팬드탭스)
string Python - find() 메서드 ★ - 문자열 처음 발견 위치 찾기/검색 (= find메서드 = 파인드 …
string Python - format() 메서드 ★★ - 포맷된 문자열 삽입. (= format메서드 = 포맷) ※ …
string Python - format_map() 메서드 ★ - 문자열 안 지정 값의 형식 지정. (= 포맷맵)
string Python - index() 메서드 ★ - 지정 문자열 처음 위치 찾기/검색. (= 인덱스)
string Python - isalnum() 메서드 - 문자열이 알파벳과 숫자인지 체크. (= isalnum메서드 = …
string Python - isalpha() 메서드 - 문자열이 알파벳뿐인지 체크. (= 이즈알파)
string Python - isdecimal() 메서드 - 문자열이 decimal 숫자뿐인지 체크 (= isdecima…
string Python - isdigit() 메서드 - 문자열이 digit 숫자뿐인지 체크. (= 이즈디지트)
string Python - isidentifier() 메서드 - 문자열이 유효한 식별자인지 체크 (= isidentif…
string Python - islower() 메서드 - 영문 문자열이 소문자뿐인지 체크. (= 이즈로우어)
string Python - isnumeric() 메서드 - 문자열이 numeric 숫자뿐인지 체크. (= 이즈뉴메릭)
string Python - isprintable() 메서드 - 문자열이 모두 인쇄 가능한지 체크. (= isprinta…
string Python - isspace() 메서드 - 문자열이 모두 공백인지 체크 (= isspace메서드 = 이즈스…
9/24
목록
찾아주셔서 감사합니다. Since 2012