늒네 기록

[python] 프로젝트 구조 짜기 - 1 본문

언어 공부 기록/python

[python] 프로젝트 구조 짜기 - 1

jaeha lee 2022. 9. 4. 19:32

 

모든 코드는 아래의 repo에 같이 정리해두었다.

 

GitHub - jaehaaheaj/python_project_structure

Contribute to jaehaaheaj/python_project_structure development by creating an account on GitHub.

github.com

 

1. 가장 간단한 구조는, main함수 안에다가 모든 기능을 다 구현해놓고 main.py를 실행시키면 원하는 결과가 출력되도록 하는 것이다. 위 repo의 sample1 브랜치를 보면, main.py에 아래와 같은 내용이 있는 것을 확인할 수 있다.

for i in range(1,int(input())+1):
    s=''
    if i%3==0:s+='fizz'
    if i%5==0:s+='buzz'
    print(s if s else i)

해당 프로젝트가 있는 경로에서 다음과 같이 main.py를 실행하면, 결과물이 출력된다.

$ py main.py
1
2
fizz
(...이어서 결과물 출력)

 

반응형
Comments