강의

멘토링

커뮤니티

Inflearn Community Q&A

dls102s9895's profile image
dls102s9895

asked

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

1. Setting the environment and solving the Kth divisor

input 질문입니다.

Written on

·

188

0

코딩테스트를 준비ㅏ다보니 input() 과 sys.input.readline() 과의 실행속도에서의 차이가 있다보니 

import sys 하고

input = sys.stdin.readline 

을 해놓고 input값을 입력하여 예시를 하는것이 코딩테스트를 위한 방식에서 괜찮은 방식인지 궁금합니다. 

python코테 준비 같이 해요!

Answer 1

0

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^

문제중에서 입력받아야 할 양이 엄청 많은 문제들이 있습니다. 그런 문제는 sys.stdin.readline()를 쓰는 것이 좋습니다. 

단 sys.stdin.readline()으로 문자열이 읽을 때는 '\n' 줄바꿈 문자까지 읽는 다는 것 조심하세요. 문자열을 읽을 때는 sys.stdin.readline().rstrip()로 읽으면 줄바꿈문자를 제거합니다.

dls102s9895's profile image
dls102s9895

asked

Ask a question