함수 매개 변수 전입 및 중복 호출 함수 사용 방법

4158 단어
from sys import argv# sys.argv ,argv list
script,file_name,input_encoding,errors = argv

def main(language_file,encoding,errors):# 
    print(">>>>main",repr(language_file),encoding,errors)
    line = language_file.readline()
    
    if line:
        print(">>there is a line:",repr(line))
        print_line(line,encoding,errors)# 
        print(">>calling main again")
        return main(language_file,encoding,errors)# 
    print(">>>>exit main")

def print_line(line,encoding,errors):
    print("print line",repr(line),encoding,errors)
    next_lan = line.strip()
    return next_lan

with open(file_name) as language_file:
    main(language_file,input_encoding,errors)

좋은 웹페이지 즐겨찾기