Python의 키워드 | 세트 1
더 많은 키워드:
16. 시도해 보세요 : 이 키워드는 예외 처리에 사용됩니다. Except 키워드를 사용하여 코드의 오류를 잡는 데 사용됩니다. 블록이 실행되는 것 외에 어떤 유형의 오류가 있는지 'try' 블록의 코드를 검사합니다.
17. 제외
18. 인상
19. 드디어 : 'try' 블록의 결과가 무엇이든 상관없이 'finally'라는 블록은 항상 실행됩니다. 자세한 기사 - Python의 예외 처리
20. 에 대한 : 이 키워드는 흐름 제어 및 반복에 사용됩니다.
우르피 자베드가 누구야?
자세한 기사 - 잠시 동안 패스
23. 수입 : 이 명령문은 현재 프로그램에 특정 모듈을 포함하는 데 사용됩니다.
24. 부터 : 일반적으로 import from과 함께 사용되며 가져온 모듈에서 특정 기능을 가져오는 데 사용됩니다.
25. 처럼
자세한 기사 -
26. 람다 : 이 키워드는 내부적으로 허용되는 명령문 없이 인라인 반환 함수를 만드는 데 사용됩니다. 자세한 기사 - 맵 필터 람다
xdxd 의미
27. 반환 : 이 키워드는 함수에서 반환하는 데 사용됩니다. 자세한 기사 -
수익률 키워드
29. 와 : 이 키워드는 컨텍스트 관리자가 정의한 메서드 내에서 코드 블록의 실행을 래핑하는 데 사용됩니다. 이 키워드는 일상적인 프로그래밍에서는 많이 사용되지 않습니다.
30. 에 : 컨테이너에 값이 포함되어 있는지 확인하는 데 사용되는 키워드입니다. 이 키워드는 컨테이너를 반복하는 데에도 사용됩니다.
31. 이다 : 이 키워드는 개체 ID를 테스트하는 데 사용됩니다. 즉, 두 개체가 모두 동일한 메모리 위치를 사용하는지 여부를 확인하는 데 사용됩니다.
Python# Python code to demonstrate working of # in and is # using 'in' to check if 's' in 'geeksforgeeks': print ('s is part of geeksforgeeks') else : print ('s is not part of geeksforgeeks') # using 'in' to loop through for i in 'geeksforgeeks': print (iend=' ') print ('r') # using is to check object identity # string is immutable( cannot be changed once allocated) # hence occupy same memory location print (' ' is ' ') # using is to check object identity # dictionary is mutable( can be changed once allocated) # hence occupy different memory location print ({} is {})
s is part of geeksforgeeks g e e k s f o r g e e k s True False
32. 글로벌
33. 비지역적 : 이 키워드는 전역과 유사하게 작동하지만 전역이 아닌 중첩된 함수의 경우 외부 함수의 변수를 가리키는 변수를 선언합니다.
Python# Python code to demonstrate working of # global and non local #initializing variable globally a = 10 # used to read the variable def read(): print (a) # changing the value of globally defined variable def mod1(): global a a = 5 # changing value of only local variable def mod2(): a = 15 # reading initial value of a # prints 10 read() # calling mod 1 function to modify value # modifies value of global a to 5 mod1() # reading modified value # prints 5 read() # calling mod 2 function to modify value # modifies value of local a to 15 doesn't effect global value mod2() # reading modified value # again prints 5 read() # demonstrating non local # inner loop changing the value of outer a # prints 10 print ('Value of a using nonlocal is : 'end='') def outer(): a = 5 def inner(): nonlocal a a = 10 inner() print (a) outer() # demonstrating without non local # inner loop not changing the value of outer a # prints 5 print ('Value of a without using nonlocal is : 'end='') def outer(): a = 5 def inner(): a = 10 inner() print (a) outer()
산출:
10 5 5 Value of a using nonlocal is : 10 Value of a without using nonlocal is : 5