AI학교

모듈 본문

Python

모듈

ai-world.tistory.com 2019. 11. 21. 11:31

 

많이 쓰는 모듈 - 관례상 별칭

import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

 

 

 

 

 

 

 

디렉터리 = 패키지

모듈 로드시 초기화 코드 

__init__

 

 

import adv_flowcontrol
모듈의 이름 :  adv_flowcontrol


import adv_function
fun :  <class 'function'>
is fun callable ?  True
200
11
12
13
15
15
고정인자 :  1 2
가변인자 :  (3, 4, 5, 6)
키워드 인자 :  {'option1': '옵션1', 'option2': '옵션2'}
option 1이 옵션1로 설정되었습니다.
30
-10
200
Words :  ['life', 'is', 'too', 'short', 'you', 'need', 'python']
Sorted Words :  ['python', 'short', 'life', 'need', 'too', 'you', 'is']
nums: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
Sorted num % 4 ASC: [4, 8, 12, 16, 20, 1, 5, 9, 13, 17, 2, 6, 10, 14, 18, 3, 7, 11, 15, 19]

adv_function.get_total(1, 2, 3, 4, 5, 6)
:

21


from adv_function import get_total

 

get_total.__module__  

:

'adv_function'

 

dir(adv_function)
:
['__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__',
 'calc',
 'fun',
 'func_args',
 'get_total',
 'incr',
 'minus',
 'nums',
 'plus',
 'scope_func',
 'scope_func2',
 'scope_func3',
 'sorted_words',
 'times',
 'words',
 'x']

 

print(get_total(1,2,3,4,5,"python"))

'Python' 카테고리의 다른 글

웹 크롤링 : Web Crawling  (0) 2019.11.22
클래스  (0) 2019.11.21
Pickle  (0) 2019.11.21
파일 입출력  (0) 2019.11.21
날짜와 시간  (0) 2019.11.20
Comments