모듈 (6) 썸네일형 리스트형 USBtoRS422_COMS_WT158 드라이버 1/5 어쩌다 보니 COMS 모듈 사서 쓰는데... 여기 두번다시 사서 쓰나 봐라... 자기들 홈페이지에 자기들 모델 드라이버가 없다고 하질 않나... CD롬이 없으면 사용하지 말라는 소리다 결국은 호텔 공용 PC에 CD 롬 있는거 확인하고 이렇게 파일 옮겨서 성공 !!! 파이썬 module 응용하기 test_module. py PI = 3.141592 def number_input() : output = input("숫자입력>") return float(output) def get_circumference(radius) : return 2 * PI *radius def get_circle_area(radius) : return PI * radius * radius main.py import test_module as test radius = test.number_input() print(test.get_circumference(radius)) print(test.get_circle_area(radius)) 결과 파이썬 os 모듈 활용하기 import os output = os.listdir(".") print("os.listdir()_:",output) print() print("폴더와 파일을 구분하기") for path in output : if os.path.isdir(path): print("폴더:",path) else : print("파일:",path) 파이썬 urllib 모듈 활용법 from urllib import request target = request.urlopen("http://google.com") output = target.read() print(output) 파이썬 time 모듈 사용 import time print("지금부터 5초 동안 정지합니다") time.sleep(5) print("프로그램을 종료합니다") 파이썬 math 모듈 사용법 import math #사인 print(math.sin(1)) #코사인 print(math.cos(1)) #탄젠트 print(math.tan(1)) #내림 print(math.floor(1.2)) #올림 print(math.ceil(1.2)) 이전 1 다음