IT 세계의 후아
[python]문자열 format, raw string 본문
f'문자열 {변수}'
# 백준 10926
print(input() + "??!")
# f-string
a = input()
print(f"{a}??!")
#프로그래머스
a, b = map(int, input().strip().split(' '))
print(f"a = {a}\nb = {b}")
print(f"{a} + {b} = {a+b}")
print("{} + {} = {}".format(a, b, a+b))
# 더 크게 합치기
def solution(a, b):
# return max(int(str(a) + str(b)), int(str(b) + str(a)))
return max(int(f"{a}{b}"), int(f"{b}{a}"))
"%d %s" % (값, 값)
# 백준 2525
h, m = map(int, input().split())
t = int(input())
res = h * 60 + m + t
if res / 60 >= 24: print("%d %d" % (res / 60 - 24, res % 60))
else: print("%d %d" % (res / 60, res % 60))
r'문자열'
파이썬 특수문자 출력 시 활용할 수 있음
#프로그래머스 특수문자 출력
print('!@#$%^&*(\\\'"<>?:;') # ", ', \ 그대로 출력하려면 앞에 \ 붙여야함
print(r'!@#$%^&*(\'"<>?:;') # raw string
#cf
path = "\content\sample_data\README.md"
data = r"{}".format(path)
'Coding > Python' 카테고리의 다른 글
[python]시간/분/초 변환 (0) | 2024.03.18 |
---|---|
[python]bool 자료형/함수, 논리연산자 (0) | 2024.03.14 |
[python]sum (0) | 2024.03.14 |
[python]map 함수 (0) | 2024.03.14 |
[python]아스키코드 (0) | 2024.01.29 |