#
으로 표현"""
또는'''
으로 묶어준다.;
를 작성하지 않지만 한줄로 표기할때는;
을 작성하여 표기 가능.(권장하지 않는다)print('hello');print('world')
print('hello
world') # -> 불가능
print('hello\
world') # -> 가능
print("""hello
world""") # -> PEP-8가이드에 따른 관례
=
을 통해 할당(assignment)된다.type()
을 활용. id()
를 활용.x = y = 5
print(x, y) #5, 5
x, y = 5, 10
print(x, y) #5, 10
a, b, c = 5, 10
#ValueError: not enough values to unpack (expected 3, got 2)
a, b = 5
# TypeError: cannot unpack non-iterable int object
x = 5
y = 10
#(1) - 임시 변수 활용하기
temp = x #임시변수에 x값을 담고
x = y #
y = temp
print(x, y)
#(2) - 파이썬스러운 방법
x, y = y, x
print(x, y)
: 변수, 함수, 모듈, 클래스 등을 식별하는데 사용되는 이름이다.
import keyword
print(keyword.kwlist)
# ['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']