나는이 2 개의 짧은 코드에 대해 2 개의 질문을 가지고 있습니다.python input() EOF 오류 및 int 유형의 반환 값?
1.
name = input('what: ')
print(name)
출력
what: 641u
Traceback (most recent call last):
File "/Users/vuthynun/PycharmProjects/untitled1/h/__init__.py", line 1, in <module>
name = input('what: ')
File "<string>", line 1
641u
^
SyntaxError: unexpected EOF while parsing
Process finished with exit code 1
은 왜 나에게이 오류를 주는가?
2.
name = input('what: ')
print(type(name))
출력 :
what: 23
<type 'int'>
Process finished with exit code 0
왜 이름 int 타입은? 나는 모든 입력이 문자열로 변환되었다고 생각했다.
제발 이해 좀 도와주세요. 그것 때문에 죽겠다.
변경'입력을()'raw_input을'에()'. 파이썬 2에서 '입력'에 무엇이든지'eval '을 호출하는 것처럼 보입니다 – roganjosh
[공식 python2 문서] (https://docs.python.org/2/library/functions.html#input)) : "일반 입력에 raw_input() 함수를 사용하는 것을 고려하십시오." – zypro