카테고리 없음
24.07.04 AI_7기
rlarudals
2024. 7. 4. 22:03
오늘은 팀과제 진행한지 2일차이다.
class Post():
def __init__(self, username, title, content):
self.author = username # 인스턴스 변수 author
self.title = title # 인스턴스 변수 title
self.content = content # 인스턴스 변수 content
print("{0}님이 게시물을 생성하였습니다." .format(self.author))
print("제목 : {0} " .format(self.title))
print("내용 : {0} ".format(self.content))
new_posts = []
def create_post():
while True:
question = input("새 게시물을 등록하시겠습니까? (y/n): ").lower()
if question == 'y':
author = input("이름을 작성해주세요:")
title = input("제목을 작성해주세요:")
content = input("내용을 작성해주세요:")
if author or title or content.isalnum():
new_post = (f"이름: {author},"
f"제목: {title},"
f"내용: {content}")
new_posts.append(new_post)
print("게시물이 등록되었습니다.")
continue
else:
print("게시물이 생성되지 않으셨습니다")
break
else:
print("등록하지 않았습니다")
break
create_post()
print("등록된 게시물들")
print(new_posts)
어제 만든것과는 달라졌다.
그 이유는 팀원과의 소통실수로 코드가 많이 안 맞았고 다시 수정을 해야할 필요가 있었기 때문이다. 사실 오늘 하면서 가장 크게 배운것이 소통인 것 같다. 코드를 아무리 잘 만들어도 결국 팀 과제 이고 팀원과의 소통이 없으면 멋진 작품을 만들기 힘들기 때문이다.
오늘 배운것들
class = 쉽게 말해 빵틀같은 개념
__init__ = 생성자
인스턴스 = 객체
self = 자신에게 적용