파이썬 3.2에서는 실행중인 함수의 나머지 부분을 멈출 수있는 방법이 있습니까?파이썬에서는 함수가 실행될 때 코드를 어떻게 멈추게합니까?
기본적으로 로그인 과정이 내 교과 과정의 컨셉으로 만들어졌으며 어디서나 답변을 찾을 수 없었습니다.
내 코드 등 데이터베이스 연결, 로그인 코드 자체 여기2- 파일, 로그 파일로의 입출력을 처리하는 기록 장치, 메인 클래스로 분할
코드 이다 그 사용자 입력을 처리하는, 나는 'quit'을 'QUIT0x0'으로 변환하는 3 행 및 4 행에 관심이있어 우연히 호출되는 종료 코드의 기회를 최소화합니다.
:def getInput(input_string, type):
result = input(input_string)
if result.lower == 'quit':
result = 'QUIT0x0'
#log the input string and result
if type == 1:
with open(logFile, 'a') as log_file:
log_file.write('[Input] %s \n[Result] %s\n' %(input_string, result))
return result
#no logging
elif type == 2:
return result
#undefined type, returns 'Undefined input type' for substring searches, and makes a log entry
else:
result = '[Undefined input type] %s' %(input_string)
output(result, 4)
return result
이
내가 4, 5 선 작업을 만들고 실행에서 함수의 나머지를 중지 할 방법에 관심이 있어요, 사용자 데이터베이스에서 사용자 레코드를 삭제 처리하는 코드입니다
'result.lower'을해야을 be result.lower() –
'quit()'코드가 우연히 호출되는 이유는 무엇입니까? –