Lab unit test 코드 중 다음 코드가 정상인지요? A. cost(self, h, y) h의 shape가 (300,1)이고 y는 (300,)이어서 (h-y)의 shape가 (300,300)이 됩니다. B. gradient(self, X, y, theta) A와 같은 이유로 (self.hypothesis_function(X, theta) - y)의 shape가 (300,300)이 됩니다.
한가지 질문이 있습니다. 입력폼에서 enter입력 이벤트가 발생했을 때 emit(@submit) 을 이용해서 컨트롤러로 이벤트를 보내는 부분인데요. Form view에서 MainController를 import 했기 때문에 MainController.onSubmit() 함수를 불러봐서 처리해줄 수 도 있지 않나요? 초보라 enter이벤트를 받은 상태에서 왜 또 @submit커스텀 이벤트를 보내는지 이유가 궁금합니다.
안녕하세요? 선생님 강의를 무척 재미있게 듣고 있는 수강생입니다. 벌써 절반을 넘겨서 혹시 다음 강의는 어떤 것으로 하실까 궁금해서 연락드립니다. 혹시 Python으로 자연어처리(NLP)쪽을 하시지 않으시는지 또한 여쭤봅니다 ^^ 사실 제가 마케팅쪽 분야에 있다보니 크롤링해서 분석할 일이 상당히 많아서요. 인터넷에 찾아봐도 Python NLP쪽은 강좌를 찾기가 하늘에 별따기네요. 아무쪼록 추후 강의 일정이나 내용 있으면 꼭 공유좀 부탁드려요 ㅎ
zip 등을 이용해서 매트릭스를 쪼개는것(정렬?)까지는 하겠는데 비교를 list comprehesion 안에서 하는 방법이 도통 떠오르지 않네요. 예를 들어 list=[(a,b),(c,d)] 에서 a=b, c=d 인지 확인하려면 [*** for rows in list] 를 어떤 아이디어로 해야할까요
([sS]+?) 와 ([sS]+) 에 따라서 실행결과가 달라지는데, 해당 차이가 명확히 이해가 되지 않아 문의드립니다. [sS]+ 사용 시 stock_results 의 size(len) 는 1 이며, stock_results[0][1] 에 마지막 <dl 전까지의 전체 텍스트가 들어갑니다. (4623 line 까지) 감사합니다 :)
안녕하세요 좋은 사람 선생님 3-4-2.py에서 rss 데이터를 다뤘었는데 기상청 자료가 말고 zdnet뉴스 rss가 있길래 텍스트 파일로 저장하려고 하는데 뭔가 잘안되는게 있어서여 rss데이터를 프린트로 찍을때(기사 제목과 내용)에 대해 내용이 정상 출력되는데 파일에 쓸때 파일 제목이 제대로 안들어가고 둘째는 파일 내용이 깨져여 이럴때 어떻게 해야되는지 알려주실수 있나여? 해결해야할 문제 (제일 하단의 반복문에서 문제가 발생) titleForFile을 파일 이름으로 하려면 어떻게 하나요? content를 내용으로 .html로 저장할때 문자열 데이터가 깨져서 나와요 또 기사 본문 같은 경우 html 태그가 섞여있는데 이럴때는 string값만 가져올수 있나여? 아니면 .txt가 아니라 html로 저장하면 웹브라우져로 기사를 볼수 있을까여? import os import sys import io from selenium import webdriver from selenium.webdriver.chrome.options import Options from bs4 import BeautifulSoup import codecs sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = ’utf-8’) sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = ’utf-8’) chrome_options = Options() chrome_options.add_argument(”–headless”) chrome_options.add_argument(’–log-level=3’) driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=r’C:/section3/webdriver/chrome/chromedriver’) driver.implicitly_wait(2) driver.get(’ http://www.zdnet.co.kr/Include2/NewsSection0020.xml ’) print(’크롬 webdriver를 이용해서 url요청을 zdnet에 날려 rss 데이터가 로딩되었습니다’) xml_soup = BeautifulSoup(driver.page_source,’html.parser’) print(xml_soup.prettify()) title_list = xml_soup.select(’item > title’) 폴더 만들기 savePath = ’c:/fast_11/html/’ try: if not(os.path.isdir(savePath)): os.makedirs(os.path.join(savePath)) print(’폴더를 생성하였습니다.’) except OSError as e: if e.errno != errno.EEXIST: print(”Failed to create directory!!!!!”) raise print(’폴더에 저장합니다.’) for i,title in enumerate(title_list): titleForFile = title.string content = title.parent.description.string content2 = titleForFile+ ’ : ’+content print(i , ’titleForFile : ’, titleForFile,’ : ’,content) if content != None: with open(’c:/fast_11/html/’+str(i)+’.txt’ ,”wt”) as f: f.write(content + ’n’) f.write(r’content2’) print(’text파일에 쓰기 완료’)
강좌를 따라하는데 html파일 읽기를 실행하면 다음과 같은 에러가 발생합니다. py파일과 html파일은 동일한 경로에 있습니다. 강좌와 같이 foot-list.html로 해도 똑같은 에러가 발생합니다. 어찌 해결 해야 되나요?? fp = open("food.html", encoding="utf-8") FileNotFoundError: [Errno 2] No such file or directory: 'food.html'