๋ฐ์ํ
Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- ์ต์
- ์ด์ง์ ๋ณํ
- mysql
- Do it
- jdbc
- ์์ด
- BFS
- ์ ํ ํฌ ํ์ด์ฌ
- ๋ฐฑ์ค
- ์ด๊ฒ์ด ์ทจ์ ์ ์ํ ์ฝ๋ฉํ ์คํธ๋ค
- ๋ค์ต์คํธ๋ผ ์๊ณ ๋ฆฌ์ฆ
- Do_it
- PYTHON
- ํฉํ ๋ฆฌ์ผ ์ง๋ฒ
- ๋ธ๋ผ์ฐ์ ์คํ
- Extended Slices
- ์๋ฐ
- DFS
- ๋ฐ์ค๊ทธ๋ํ
- sql
- java
- 2BPerfect
- ํ๋ก๊ทธ๋๋จธ์ค
- ํ์ ๋ณ์
- ์ง ๊ฐ ์์ธก ๋ถ์
- np.zeros_like
- dacon
- matplotlib
- ์ฐธ์กฐ ๋ณ์
- MacOS
Archives
- Today
- Total
๐ฆ ๊ณต๋ฃก์ด ๋์!
python_re_study...3 ๋ณธ๋ฌธ
- ํด๋์ค
a = Cookie()
b = Cookie()
๊ฐ์ฒด์์ฑ

- ์์ฑ์
class FourCal:
def __init__(self, first, second):
self.first = first
self.second = second
- ์์
class MoreFourCal(FourCal):
pass
- ์ค๋ฒ๋ผ์ด๋ฉ
class SafeFourCal(FourCal):
def div(self):
if self.second == 0: # ๋๋๋ ๊ฐ์ด 0์ธ ๊ฒฝ์ฐ 0์ ๋ฆฌํดํ๋๋ก ์์
return 0
else:
return self.first / self.second
- ํด๋์ค ๋ณ์
class Family:
lastname = "๊น"
- ๋ชจ๋
import ๋ชจ๋์ด๋ฆ ๋ชจ๋.add from mod1 import add add() from mod1 import *
- [ ] if name == "main": ์ ์๋ฏธ
if __name__ == "__main__"์ ์ฌ์ฉํ๋ฉด C:\\doit>python mod1.py์ฒ๋ผ ์ง์ ์ด ํ์ผ์ ์คํ ํ์ ๋๋ __name__ == "__main__"์ด ์ฐธ์ด ๋์ด if๋ฌธ ๋ค์ ๋ฌธ์ฅ์ด ์ํ๋๋ค. ๋ฐ๋๋ก ๋ํํ ์ธํฐํ๋ฆฌํฐ๋ ๋ค๋ฅธ ํ์ผ์์ ์ด ๋ชจ๋์ ๋ถ๋ฌ์ ์ฌ์ฉํ ๋๋ __name__ == "__main__"์ด ๊ฑฐ์ง์ด ๋์ด if๋ฌธ ๋ค์ ๋ฌธ์ฅ ์ด ์ํ๋์ง ์๋๋ค.
**__name__ ๋ณ์๋?** ํ์ด์ฌ์ __name__ ๋ณ์๋ ํ์ด์ฌ์ด ๋ด๋ถ์ ์ผ๋ก ์ฌ์ฉํ๋ ํน๋ณํ ๋ณ์ ์ด๋ฆ์ด๋ค. ๋ง์ฝ C:\\doit>python mod1.py์ฒ๋ผ ์ง์ mod1.py ํ์ผ์ ์คํํ ๊ฒฝ์ฐ mod1.py์ __name__ ๋ณ์ ์๋ __main__ ๊ฐ์ด ์ ์ฅ๋๋ค. ํ์ง๋ง ํ์ด์ฌ ์ ธ์ด๋ ๋ค๋ฅธ ํ์ด์ฌ ๋ชจ๋์์ mod1์ import ํ ๊ฒฝ์ฐ์๋ mod1.py์ __name__ ๋ณ์์๋ mod1.py์ ๋ชจ๋ ์ด๋ฆ ๊ฐ mod1์ด ์ ์ฅ๋๋ค.
- ๋ชจ๋ ๋ถ๋ฌ์ค๋ ๋ฒ
import sys sys.path sys.path.append("")
set PYTHONPATH=๊ฒฝ๋ก
- ํจํค์ง
>>> import game.sound.echo
>>> game.sound.echo.echo_test()
echo
>>> from game.sound import echo
>>> echo.echo_test()
echo
>>> from game.sound.echo import echo_test
>>> echo_test()
echo
-
>>> import game >>> game.sound.echo.echo_test() >>> import game.sound.echo.echo_test
- ์์ ๊ฒ์ ๋ถ๊ฐ๋ฅ import game์ ์ํํ๋ฉด game ๋๋ ํฐ๋ฆฌ์ __init__.py์ ์ ์ํ ๊ฒ๋ง ์ฐธ์กฐํ ์ ์๋ค.
- ๋ํธ ์ฐ์ฐ์(.)๋ฅผ ์ฌ์ฉํด์ import a.b.c์ฒ๋ผ importํ ๋ ๊ฐ์ฅ ๋ง์ง๋ง ํญ๋ชฉ์ธ c๋ ๋ฐ๋์ ๋ชจ๋ ๋๋ ํจํค์ง์ฌ์ผ๋ง ํ๋ค.
์ฐธ๊ณ : https://wikidocs.net/book/1
์ ํ ํฌ ํ์ด์ฌ
** ์ ํ ํฌ ํ์ด์ฌ ์คํ๋ผ์ธ ์ฑ (๊ฐ์ ํ) ์ถ๊ฐ !! (2019.06) ** * [์ฑ ๊ตฌ์ ์๋ด](https://wikidocs.net/4321) ์ด ์ฑ ์ ํ์ด์ฌ ...
wikidocs.net
๋ฐ์ํ
'Development > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
python_re_study...5 (0) | 2021.12.19 |
---|---|
python_re_study...4 (0) | 2021.12.18 |
python_re_study...2 (0) | 2021.12.15 |
python_re_study...1 (0) | 2021.12.15 |
Python Library(os) (0) | 2021.12.07 |
Comments