- [ Python ]11. 파일 및 디렉토리 (Python file & directory)2024-08-02 15:22:26directory directory는 한국말로 폴더 정도로 변역됩니다.absolute path (절대 경로)절대적인 기준(시작 폴더)으로 경유한 경로를 기입하는 방식입니다.ex) C:\Users\username\Desktop\filerelative path (상대 경로)상대적인 기준(현제 폴더)으로 경유한 경로를 기입하는 방식입니다.dot(.)은 present directory(현제 폴더)의 위치를 나타냅니다.(생략가능)ex).\\subdirectory(하위 폴더) or filedot 두개(..)는 parent directory(상위 폴더)로 이동합니다ex)..(previous directory:상위 폴더)\subdirectory(하위 폴더) or file file data를 저장하는 입출력하는 기본적인..
- [ Python ]10. 클래스 (Python Class)2024-07-25 14:52:20class class class_name:-method:의 구성으로 되어있습니다.class의 이름은 통상적으로 대문자로 시작합니다.method (함수)클래스 내의 함수를 method(메서드)라고 부릅니다.def method_name으로 선언합니다.class_name.method()로 호출합니다.class Class_: def method1(): print("method1")Class_.method1()더보기method1비공개 method는 class 외부에서 사용할 수 없습니다.def __method_name으로 선언합니다.class Class_: def __method1(): print("method1") def method2(): Class_.__..
- [ Python ]9. 함수(Python function)2024-07-16 14:39:56defdef의 이름하고 변수의 이름이 중복되면 안 됩니다.def function_name(var):-code의 구조를 가집니다. (var= variabld(변수), val=value(불변 변수, 값))def hi(): print("Hello word")hi()더보기Hello worddef-input함수는 인자를 받을 수 있습니다.def say(x): print(x)say("hi")더보기hidef-input_option:default함수의 인자는 기본값을 보유할 수 있습니다.def(input,input_option=default)의 순서로 사용해야 합니다.def say(x="hello"): return xhi=say()print(hi)더보기hellodef-input(*var)input은 *..
- [ Python ]8. 예외처리 (Python Exception Handling)2024-07-12 15:58:19try 문 try(오류 검출)-except(예외처리)-else-finally는 오류를 처리하는 방법입니다.try-excepttry진행 중 error가 생기면 try 문을 중지하고 except를 진행합니다. 이후 작성된 code를 실행시킵니다.try: print("try") print(a) # errorexcept: print("except")print("Progress")더보기tryexceptProgressexcept에 오류명을 적어서 특정 오류만 검출할 수 있습니다.여러 개의 except를 만들어서 사용가능합니다.먼저 검출된 error의 except만 실핻됩니다.as는 특정 객체를 변수에 할당하는 명령어입니다.try: print("try") print(a) # error ..
- [ Python ]7. 반복문(Python Loop)2024-07-12 10:19:47for 문 for variable(변수) in Sequence Tpye data(시퀀스 자료)의 기본 문법으로 가집니다.시퀀스 index 순서대로 변수에 적용되어 반복문을 실행합니다.list_=[[1,2],[2,3],[3,4]]for i in list_: print(i)더보기[1, 2][2, 3][3, 4]시퀀스 데이터 안에 다른 시퀀스 데이터가 있으면 인자의 수만큼 변수를 지정할 수 있습니다.list_=[[1,2],[2,3],[3,4]]for i,j in list_: print(i,j)더보기1 22 33 4 While 문 while(조건)은 조건이 Ture(참)일 때 조건이 Fales(거짓)가 될 때까지 반복합니다.cnt=0while cnt더보기01234while (조건=True)가 불변하면..
- [ Python ]6. 조건문 (Python Conditionals)2024-07-10 16:19:21if 문 if(조건식)-elif(조건식)-else로 구성되어 있습니다.조건식이 참에 해당하는 조건(True)을 만족하면 해당 구절(if, elif, else)에 명령어를 실행합니다.ifif(조건식)가 참이면 if를 실행시킵니다.if True: print("if true")더보기if trueif-elseif(조건식)가 거짓이면 else를 실행시킵니다.if False: print("if true")else: print("if False")더보기if Falseif-else는 한 줄로 줄일 수 있습니다.print('if')if False else print("else")더보기elseif-elif-elseif(조건식)가 거짓이고 elif(조건식)가 참이면 elif를 실행시킵니다.elif(조건식)도..