콘솔(Consol)

이상해씨·2023년 4월 6일
0

AI 기초

목록 보기
9/15

콘솔 IO

  • 데이터를 입출력하는 방법 중 터미널 환경에서 콘솔을 사용한다.
  • input()함수 : 사용자에게 함수내용을 입력받음.
print("What is your name?")
name =str(input("My name is "))
print("Hi " ,name) 

formatting

  • 출력양식 지정

1) % string

print('%s%s' %('mother', 'father))

2) format 함수

print('{} {}'.format(1,2))

2-1) %format

print("I love My %5.2d cats." %3)
# 5칸 whitespce하고 소숫점2자리 출력해줘

2-2) str.format

print("My family is {0},{1}, and me.".format(mother, father))
print("temperature is {0:.2f}C".format(15.78543)"
# 0번째는 소숫점 2자리까지 출력해줘

3) fsting

name ="H"
age=3
weight=10.333
print(f"HI , {name}. You are {age}")
print(f"HI , {name:*^5}.") # **H**
print(f"HI , {name:*<7.2f}.") # 10.33**

padding

print({0},{1:<10s}.format(1,2)) #<왼쪽 정렬, >오른족 정렬

섭씨와 화씨 변환

참고

profile
공부에는 끝이 없다

0개의 댓글