내장 함수 예
input : 사용자 입력을 받는 함수
import pickle
import random # 외장 함수
language = input("무슨 언어를 좋아하세요?")
print("{0}은 아주 좋은 언어입니다.".format(language))
dir : 어떤 객체를 넘겨줬을 때 그 객체가 어떤 변수와 함수를 가지고 있는지 표시
print(dir())
print(dir())
print(dir())
print(dir(random))
lst = [1, 2, 3]
print(dir(lst))
name = "Jim"
print(dir(name))
- 밑에 사이트에서 내장 함수 참조 -
https://docs.python.org/3/library/functions.html
Built-in Functions — Python 3.8.4rc1 documentation
Built-in Functions The Python interpreter has a number of functions and types built into it that are always available. They are listed here in alphabetical order. abs(x) Return the absolute value of a number. The argument may be an integer or a floating po
docs.python.org
외장함수
glob : 경로 내의 폴더 / 파일 목록 조회 (윈도우 dir)
import glob
print(glob.glob("*.py")) # 확장자가 py 인 모든 파일
os : 운영ㅊ제에서 제공하는 기본 기능
import os
print(os.getcwd()) # 현재 디렉토리를 표시
folder = "sample_dir"
if os.path.exists(folder):
print("이미 존재하는 폴더입니다.")
os.rmdir(folder)
print(folder, "폴더를 삭제하였습니다.")
else:
os.makedirs(folder) # 폴더 생성
print(folder, "폴더를 생성하였습니다.")
print(os.listdir())
import time # 시간 관련 함수
print(time.localtime())
print(time.strftime("%Y-%m-%d %H:%M:%S"))
import datetime
print("오늘 날짜는 ", datetime.date.today())
timedelta : 두 날짜 사이의 간격
today = datetime.date.today() # 오늘 날짜 저장
td = datetime.timedelta(days=100) # 100일 저장
print("우리가 만난지 100일은", today + td) # 오늘부터 100일 후
- 밑에 사이트에서 외장 함수 참조 -
https://docs.python.org/3/py-modindex.html
Python Module Index — Python 3.8.4rc1 documentation
numbers Numeric abstract base classes (Complex, Real, Integral, etc.).
docs.python.org
'Python' 카테고리의 다른 글
| Python- pip install (0) | 2020.07.08 |
|---|---|
| Python-패키지 사용법 (0) | 2020.07.08 |
| Python-모듈 사용법 (0) | 2020.07.08 |
| Python-init (0) | 2020.07.05 |
| Python-class (스타크래프트 예시) (0) | 2020.07.05 |


