def sanitize(time_string): if '-' in time_string : splitter = '-' elif ':' in time_string : splitter = ':' else : return(time_string) (mins, secs) = time_string.split(splitter) return(mins + '.' + secs) def get_coach_data(filename): try : with open(filename) as f: data = f.readline() return(data.strip().split(',')) except IOError as ioerr: print('File error: ' + str(ioerr)) return (None) sarah =..
두 가지 정렬 방법 원본 정렬(In-place sorting) 변환하고 대체합니다. 리스트의 sort() 사용 사본 정렬(Copied sorting) 변환하고 반환합니다. 내장함수 sorted() 사용 문자열 정렬 우선순위 하이픈 - 점 - 콜론 >>> data = [6, 3, 1, 2, 4, 5] >>> data [6, 3, 1, 2, 4, 5] >>> data [6, 3, 1, 2, 4, 5] >>> data.sort() >>> data [1, 2, 3, 4, 5, 6] >>> data = [6, 3, 1, 2, 4, 5] >>> data [6, 3, 1, 2, 4, 5] >>> data2 = sorted(data) >>> data [6, 3, 1, 2, 4, 5] >>> data2 [1, 2, 3,..
파일 쓰기 import os man = [] other = [] """ 파일 읽기 """ try : data = open('sketch.txt') for each_line in data : try : (role, line_spoken) = each_line.split(':', 1) line_spoken = line_spoken.strip() if role == 'Man' : man.append(line_spoken) elif role == 'Other Man' : other.append(line_spoken) except ValueError: pass data.close() except IOError: print('The data file is missing!') """ 파일 쓰기 """ try : ou..