Python
Python(1) 시작
UserDonghu
2023. 9. 8. 17:35
파이썬은 조금 공부를 하였기 때문에 블로그에는 내가 몰랐던 부분 혹은 헷갈리는 부분만 정리.
https://colab.research.google.com/drive/19o3KXnRPZeeW73emy73nApBwI2emS3Sr?usp=sharing
주석
# 한줄 주석
'''
여러줄
주석
입니다
'''
출력
x = 'hello'
print(x, x, sep='-') # hello-hello
print('010', '0000', '1000', sep='-') # 010-0000-1000
print('010', '0000', '1000', end='-')
print('Hello World', end='~') # 010 0000 1000-Hello World~
변수
x = 10
y = x
z = y
x = 20
print(y, z) # 10, 10
str(10) + str(10) # '1010'
# 중요한 포인트는 +도 어딘가에 '정의'되어 있다는 것
class str(str):
def __add__(self, other):
return "hello"
str(10) + str(10) # hello