• 카테고리

    질문 & 답변
  • 세부 분야

    데이터 분석

  • 해결 여부

    미해결

이렇게 코딩했더니

20.04.28 22:37 작성 조회수 224

0

콘솔창에 이렇게 뜨는데  utf-8 이쪽에서 뭔가 에러가난거같은데 어떻게해야하죠?

  • section4-1.py
  • forecast.xml
<atom-text-editor class="editor has-selection" data-encoding="utf8" data-grammar="source python" tabindex="-1" style="box-sizing:border-box;display:flex;cursor:text;font-family:var(--editor-font-family);font-size:var(--editor-font-size);line-height:var(--editor-line-height);user-select:none;background-color:#282c34;color:#abb2bf;position:absolute;top:0px;right:0px;bottom:0px;left:0px;contain:size"> <div style="box-sizing:border-box;position:relative;contain:strict;overflow:hidden;background-color:inherit;height:579px;width:868px"> <div class="gutter-container" style="box-sizing:border-box;width:min-content;background-color:inherit;cursor:default;position:relative;z-index:1"> <div style="box-sizing:border-box;will-change:transform;display:flex;transform:translateY(0px)"> <div class="gutter line-numbers" gutter-name="line-number" style="box-sizing:border-box;overflow:hidden;z-index:0;text-align:right;min-width:1em;background-color:inherit;position:relative;width:max-content;height:569px"> <div class="line-number dummy" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#636d83;-webkit-font-smoothing:antialiased;visibility:hidden"> <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div style="box-sizing:border-box;contain:layout style;position:absolute;top:0px;height:114px;width:39px;transform:translateY(0px)"> <div class="line-number cursor-line" data-buffer-row="0" data-screen-row="0" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">1 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="1" data-screen-row="1" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">2 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="2" data-screen-row="2" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">3 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="3" data-screen-row="3" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">4 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="4" data-screen-row="4" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">5 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="5" data-screen-row="5" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">6 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> </div> <div style="box-sizing:border-box;contain:layout style;position:absolute;top:0px;height:114px;width:39px;transform:translateY(114px)"> <div class="line-number cursor-line" data-buffer-row="6" data-screen-row="6" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">7 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="7" data-screen-row="7" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">8 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="8" data-screen-row="8" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">9 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="9" data-screen-row="9" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">10 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="10" data-screen-row="10" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">11 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="11" data-screen-row="11" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">12 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> </div> <div style="box-sizing:border-box;contain:layout style;position:absolute;top:0px;height:114px;width:39px;transform:translateY(228px)"> <div class="line-number cursor-line" data-buffer-row="12" data-screen-row="12" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">13 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="13" data-screen-row="13" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">14 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number foldable cursor-line" data-buffer-row="14" data-screen-row="14" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">15 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="15" data-screen-row="15" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">16 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="16" data-screen-row="16" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">17 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="17" data-screen-row="17" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">18 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> </div> <div style="box-sizing:border-box;contain:layout style;position:absolute;top:0px;height:114px;width:39px;transform:translateY(342px)"> <div class="line-number cursor-line" data-buffer-row="18" data-screen-row="18" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">19 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number foldable cursor-line" data-buffer-row="19" data-screen-row="19" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">20 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="20" data-screen-row="20" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">21 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="21" data-screen-row="21" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">22 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number foldable cursor-line" data-buffer-row="22" data-screen-row="22" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">23 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number cursor-line" data-buffer-row="23" data-screen-row="23" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">24 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> </div> <div style="box-sizing:border-box;contain:layout style;position:absolute;top:0px;height:38px;width:39px;transform:translateY(456px)"> <div class="line-number cursor-line" data-buffer-row="24" data-screen-row="24" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#abb2bf;-webkit-font-smoothing:antialiased;background-color:#3a3f4b;width:39px">25 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> <div class="line-number" data-buffer-row="25" data-screen-row="25" style="box-sizing:border-box;padding-left:0.5em;white-space:nowrap;opacity:0.6;position:relative;color:#636d83;-webkit-font-smoothing:antialiased;width:39px">26 <div class="icon-right" style="box-sizing:border-box;display:inline-block;visibility:hidden;opacity:0.6;padding:0px 0.4em;color:#abb2bf"></div> </div> </div> </div> </div> </div> <div class="scroll-view" style="box-sizing:border-box;position:absolute;contain:strict;overflow:hidden;top:0px;bottom:0px;background-color:inherit;left:39px;width:829px"> <div style="box-sizing:border-box;contain:strict;overflow:hidden;background-color:inherit;width:819px;height:569px;will-change:transform;transform:translate(0px, 0px)"> <div class="lines" style="box-sizing:border-box;position:absolute;contain:strict;overflow:hidden;width:819px;height:569px"> <div class="highlights" style="box-sizing:border-box;contain:strict;position:absolute;overflow:hidden;user-select:none;height:569px;width:819px"> <div class="highlight selection" style="box-sizing:border-box;font-weight:bold;border-radius:2px;color:#d7dae0;background:none;padding:0px"> <div class="region selection" style="box-sizing:border-box;pointer-events:none;z-index:-1;background-color:#3e4451;position:absolute;top:0px;left:0px;right:0px;height:19px"></div> <div class="region selection" style="box-sizing:border-box;pointer-events:none;z-index:-1;background-color:#3e4451;position:absolute;top:19px;left:0px;height:437px;right:0px"></div> <div class="region selection" style="box-sizing:border-box;pointer-events:none;z-index:-1;background-color:#3e4451;position:absolute;top:456px;left:0px;width:100px;height:19px"></div> </div> </div> <div style="box-sizing:border-box;contain:layout style;position:absolute;height:114px;width:819px;transform:translateY(0px)"> <div class="line" data-screen-row="0" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="syntax--keyword syntax--control syntax--import syntax--python" style="box-sizing:border-box;color:#c678dd">import</span> sys</span></span></div> <div class="line" data-screen-row="1" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="syntax--keyword syntax--control syntax--import syntax--python" style="box-sizing:border-box;color:#c678dd">import</span> io</span></span></div> <div class="line" data-screen-row="2" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="syntax--keyword syntax--control syntax--import syntax--python" style="box-sizing:border-box;color:#c678dd">import</span> <span class="syntax--variable syntax--other syntax--object syntax--python" style="box-sizing:border-box;color:#e06c75">urllib</span><span class="syntax--punctuation syntax--separator syntax--property syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--variable syntax--other syntax--property syntax--python" style="box-sizing:border-box;color:#e06c75">request</span> <span class="syntax--keyword syntax--other syntax--python" style="box-sizing:border-box;color:#c678dd">as</span> req</span></span></div> <div class="line" data-screen-row="3" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="syntax--keyword syntax--control syntax--import syntax--from syntax--python" style="box-sizing:border-box;color:#c678dd">from</span> bs4 <span class="syntax--keyword syntax--control syntax--import syntax--python" style="box-sizing:border-box;color:#c678dd">import</span> BeautifulSoup</span></span></div> <div class="line" data-screen-row="4" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="syntax--keyword syntax--control syntax--import syntax--python" style="box-sizing:border-box;color:#c678dd">import</span> <span class="syntax--variable syntax--other syntax--object syntax--python" style="box-sizing:border-box;color:#e06c75">os</span><span class="syntax--punctuation syntax--separator syntax--property syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--variable syntax--other syntax--property syntax--python" style="box-sizing:border-box;color:#e06c75">path</span> <span class="syntax--comment syntax--line syntax--number-sign syntax--python" style="box-sizing:border-box;color:#5c6370;font-style:italic"><span class="syntax--punctuation syntax--definition syntax--comment syntax--python" style="box-sizing:border-box;color:#5c6370;font-style:italic">#</span>os.path 내에는 경로반환, 경로추출 등 파일/디렉토리 경로와 관련된 많은 함수를 제공해준다.</span></span></span></div> <div class="line" data-screen-row="5" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"></span></div> </div> <div style="box-sizing:border-box;contain:layout style;position:absolute;height:114px;width:819px;transform:translateY(114px)"> <div class="line" data-screen-row="6" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="syntax--variable syntax--other syntax--object syntax--python" style="box-sizing:border-box;color:#e06c75">sys</span><span class="syntax--punctuation syntax--separator syntax--property syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--variable syntax--other syntax--property syntax--python" style="box-sizing:border-box;color:#e06c75">stdout</span> <span class="syntax--keyword syntax--operator syntax--assignment syntax--python" style="box-sizing:border-box;color:#c678dd">=</span> <span class="syntax--variable syntax--other syntax--object syntax--python" style="box-sizing:border-box;color:#e06c75">io</span><span class="syntax--meta syntax--method-call syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--punctuation syntax--separator syntax--method syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--entity syntax--name syntax--function syntax--python" style="box-sizing:border-box;color:#61afef">TextIOWrapper</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">(</span><span class="syntax--meta syntax--method-call syntax--arguments syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--variable syntax--other syntax--object syntax--python" style="box-sizing:border-box;color:#e06c75">sys</span><span class="syntax--punctuation syntax--separator syntax--property syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--variable syntax--other syntax--object syntax--property syntax--python" style="box-sizing:border-box;color:#e06c75">stdout</span><span class="syntax--meta syntax--method-call syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--punctuation syntax--separator syntax--method syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--entity syntax--name syntax--function syntax--python" style="box-sizing:border-box;color:#61afef">detach</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">(</span><span class="syntax--meta syntax--method-call syntax--arguments syntax--python" style="box-sizing:border-box;color:#abb2bf"></span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">)</span></span><span class="syntax--punctuation syntax--separator syntax--arguments syntax--python" style="box-sizing:border-box">,</span> <span class="syntax--variable syntax--parameter syntax--function syntax--python" style="box-sizing:border-box;color:#d19a66">encoding</span> <span class="syntax--keyword syntax--operator syntax--assignment syntax--python" style="box-sizing:border-box;color:#c678dd">=</span> <span class="syntax--string syntax--quoted syntax--single syntax--single-line syntax--python" style="box-sizing:border-box;color:#98c379"><span class="syntax--punctuation syntax--definition syntax--string syntax--begin syntax--python" style="box-sizing:border-box;color:#98c379">'</span>utf-8<span class="syntax--punctuation syntax--definition syntax--string syntax--end syntax--python" style="box-sizing:border-box;color:#98c379">'</span></span></span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">)</span></span></span></span></div> <div class="line" data-screen-row="7" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="syntax--variable syntax--other syntax--object syntax--python" style="box-sizing:border-box;color:#e06c75">sys</span><span class="syntax--punctuation syntax--separator syntax--property syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--variable syntax--other syntax--property syntax--python" style="box-sizing:border-box;color:#e06c75">stderr</span> <span class="syntax--keyword syntax--operator syntax--assignment syntax--python" style="box-sizing:border-box;color:#c678dd">=</span> <span class="syntax--variable syntax--other syntax--object syntax--python" style="box-sizing:border-box;color:#e06c75">io</span><span class="syntax--meta syntax--method-call syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--punctuation syntax--separator syntax--method syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--entity syntax--name syntax--function syntax--python" style="box-sizing:border-box;color:#61afef">TextIOWrapper</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">(</span><span class="syntax--meta syntax--method-call syntax--arguments syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--variable syntax--other syntax--object syntax--python" style="box-sizing:border-box;color:#e06c75">sys</span><span class="syntax--punctuation syntax--separator syntax--property syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--variable syntax--other syntax--object syntax--property syntax--python" style="box-sizing:border-box;color:#e06c75">stderr</span><span class="syntax--meta syntax--method-call syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--punctuation syntax--separator syntax--method syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--entity syntax--name syntax--function syntax--python" style="box-sizing:border-box;color:#61afef">detach</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">(</span><span class="syntax--meta syntax--method-call syntax--arguments syntax--python" style="box-sizing:border-box;color:#abb2bf"></span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">)</span></span><span class="syntax--punctuation syntax--separator syntax--arguments syntax--python" style="box-sizing:border-box">,</span> <span class="syntax--variable syntax--parameter syntax--function syntax--python" style="box-sizing:border-box;color:#d19a66">encoding</span> <span class="syntax--keyword syntax--operator syntax--assignment syntax--python" style="box-sizing:border-box;color:#c678dd">=</span> <span class="syntax--string syntax--quoted syntax--single syntax--single-line syntax--python" style="box-sizing:border-box;color:#98c379"><span class="syntax--punctuation syntax--definition syntax--string syntax--begin syntax--python" style="box-sizing:border-box;color:#98c379">'</span>utf-8<span class="syntax--punctuation syntax--definition syntax--string syntax--end syntax--python" style="box-sizing:border-box;color:#98c379">'</span></span></span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">)</span></span></span></span></div> <div class="line" data-screen-row="8" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"></span></div> <div class="line" data-screen-row="9" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"></span></div> <div class="line" data-screen-row="10" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="syntax--comment syntax--line syntax--number-sign syntax--python" style="box-sizing:border-box;color:#5c6370;font-style:italic"><span class="syntax--punctuation syntax--definition syntax--comment syntax--python" style="box-sizing:border-box;color:#5c6370;font-style:italic">#</span>다운로드 urll</span></span></span></div> <div class="line" data-screen-row="11" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box">url <span class="syntax--keyword syntax--operator syntax--assignment syntax--python" style="box-sizing:border-box;color:#c678dd">=</span> <span class="syntax--string syntax--quoted syntax--double syntax--single-line syntax--python" style="box-sizing:border-box;color:#98c379"><span class="syntax--punctuation syntax--definition syntax--string syntax--begin syntax--python" style="box-sizing:border-box;color:#98c379">"</span><span class="syntax--markup syntax--underline syntax--link syntax--http syntax--hyperlink" style="box-sizing:border-box;text-decoration:underline;color:#56b6c2">http://www.weather.go.kr/weather/lifenindustry/sevice_rss.jsp</span><span class="syntax--punctuation syntax--definition syntax--string syntax--end syntax--python" style="box-sizing:border-box;color:#98c379">"</span></span></span></span></div> </div> <div style="box-sizing:border-box;contain:layout style;position:absolute;height:114px;width:819px;transform:translateY(228px)"> <div class="line" data-screen-row="12" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box">savename <span class="syntax--keyword syntax--operator syntax--assignment syntax--python" style="box-sizing:border-box;color:#c678dd">=</span> <span class="syntax--string syntax--quoted syntax--double syntax--single-line syntax--python" style="box-sizing:border-box;color:#98c379"><span class="syntax--punctuation syntax--definition syntax--string syntax--begin syntax--python" style="box-sizing:border-box;color:#98c379">"</span>c:/section4/forecast.xml<span class="syntax--punctuation syntax--definition syntax--string syntax--end syntax--python" style="box-sizing:border-box;color:#98c379">"</span></span></span></span></div> <div class="line" data-screen-row="13" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"></span></div> <div class="line" data-screen-row="14" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="syntax--keyword syntax--control syntax--conditional syntax--python" style="box-sizing:border-box;color:#c678dd">if</span> <span class="syntax--keyword syntax--operator syntax--logical syntax--python" style="box-sizing:border-box;color:#c678dd">not</span> <span class="syntax--variable syntax--other syntax--object syntax--python" style="box-sizing:border-box;color:#e06c75">os</span><span class="syntax--punctuation syntax--separator syntax--property syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--variable syntax--other syntax--object syntax--property syntax--python" style="box-sizing:border-box;color:#e06c75">path</span><span class="syntax--meta syntax--method-call syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--punctuation syntax--separator syntax--method syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--entity syntax--name syntax--function syntax--python" style="box-sizing:border-box;color:#61afef">exists</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">(</span><span class="syntax--meta syntax--method-call syntax--arguments syntax--python" style="box-sizing:border-box;color:#abb2bf">savename</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">)</span></span>:</span></span></div> <div class="line" data-screen-row="15" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="leading-whitespace" style="box-sizing:border-box"> </span><span class="syntax--variable syntax--other syntax--object syntax--python" style="box-sizing:border-box;color:#e06c75">req</span><span class="syntax--meta syntax--method-call syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--punctuation syntax--separator syntax--method syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--entity syntax--name syntax--function syntax--python" style="box-sizing:border-box;color:#61afef">urlretrieve</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">(</span><span class="syntax--meta syntax--method-call syntax--arguments syntax--python" style="box-sizing:border-box;color:#abb2bf">url<span class="syntax--punctuation syntax--separator syntax--arguments syntax--python" style="box-sizing:border-box">,</span> savename</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">)</span></span></span></span></div> <div class="line" data-screen-row="16" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"></span></div> <div class="line" data-screen-row="17" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="syntax--punctuation syntax--whitespace syntax--comment syntax--leading syntax--python" style="box-sizing:border-box;color:#5c6370;font-style:italic"><span class="leading-whitespace" style="box-sizing:border-box"> </span></span><span class="syntax--comment syntax--line syntax--number-sign syntax--python" style="box-sizing:border-box;color:#5c6370;font-style:italic"><span class="syntax--punctuation syntax--definition syntax--comment syntax--python" style="box-sizing:border-box;color:#5c6370;font-style:italic">#</span>BeautifulSoup 파싱</span></span></span></div> </div> <div style="box-sizing:border-box;contain:layout style;position:absolute;height:114px;width:819px;transform:translateY(342px)"> <div class="line" data-screen-row="18" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box">xml <span class="syntax--keyword syntax--operator syntax--assignment syntax--python" style="box-sizing:border-box;color:#c678dd">=</span> <span class="syntax--meta syntax--function-call syntax--python" style="box-sizing:border-box"><span class="syntax--support syntax--function syntax--builtin syntax--python" style="box-sizing:border-box;color:#56b6c2">open</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">(</span><span class="syntax--meta syntax--function-call syntax--arguments syntax--python" style="box-sizing:border-box">savename<span class="syntax--punctuation syntax--separator syntax--arguments syntax--python" style="box-sizing:border-box">,</span> <span class="syntax--string syntax--quoted syntax--single syntax--single-line syntax--python" style="box-sizing:border-box;color:#98c379"><span class="syntax--punctuation syntax--definition syntax--string syntax--begin syntax--python" style="box-sizing:border-box;color:#98c379">'</span>r<span class="syntax--punctuation syntax--definition syntax--string syntax--end syntax--python" style="box-sizing:border-box;color:#98c379">'</span></span><span class="syntax--punctuation syntax--separator syntax--arguments syntax--python" style="box-sizing:border-box">,</span> <span class="syntax--variable syntax--parameter syntax--function syntax--python" style="box-sizing:border-box;color:#d19a66">encoding</span><span class="syntax--keyword syntax--operator syntax--assignment syntax--python" style="box-sizing:border-box;color:#c678dd">=</span><span class="syntax--string syntax--quoted syntax--double syntax--single-line syntax--python" style="box-sizing:border-box;color:#98c379"><span class="syntax--punctuation syntax--definition syntax--string syntax--begin syntax--python" style="box-sizing:border-box;color:#98c379">"</span>utf-8<span class="syntax--punctuation syntax--definition syntax--string syntax--end syntax--python" style="box-sizing:border-box;color:#98c379">"</span></span></span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">)</span></span><span class="syntax--meta syntax--method-call syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--punctuation syntax--separator syntax--method syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--entity syntax--name syntax--function syntax--python" style="box-sizing:border-box;color:#61afef">read</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">(</span><span class="syntax--meta syntax--method-call syntax--arguments syntax--python" style="box-sizing:border-box;color:#abb2bf"></span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">)</span></span></span></span></div> <div class="line" data-screen-row="19" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box">soup <span class="syntax--keyword syntax--operator syntax--assignment syntax--python" style="box-sizing:border-box;color:#c678dd">=</span> <span class="syntax--meta syntax--function-call syntax--python" style="box-sizing:border-box"><span class="syntax--entity syntax--name syntax--function syntax--python" style="box-sizing:border-box;color:#61afef">BeautifulSoup</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">(</span><span class="syntax--meta syntax--function-call syntax--arguments syntax--python" style="box-sizing:border-box">xml<span class="syntax--punctuation syntax--separator syntax--arguments syntax--python" style="box-sizing:border-box">,</span> <span class="syntax--string syntax--quoted syntax--single syntax--single-line syntax--python" style="box-sizing:border-box;color:#98c379"><span class="syntax--punctuation syntax--definition syntax--string syntax--begin syntax--python" style="box-sizing:border-box;color:#98c379">'</span>html.parser<span class="syntax--punctuation syntax--definition syntax--string syntax--end syntax--python" style="box-sizing:border-box;color:#98c379">'</span></span></span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">)</span></span></span></span></div> <div class="line" data-screen-row="20" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"></span></div> <div class="line" data-screen-row="21" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="syntax--punctuation syntax--whitespace syntax--comment syntax--leading syntax--python" style="box-sizing:border-box;color:#5c6370;font-style:italic"><span class="leading-whitespace" style="box-sizing:border-box"> </span></span><span class="syntax--comment syntax--line syntax--number-sign syntax--python" style="box-sizing:border-box;color:#5c6370;font-style:italic"><span class="syntax--punctuation syntax--definition syntax--comment syntax--python" style="box-sizing:border-box;color:#5c6370;font-style:italic">#</span>지역확인</span></span></span></div> <div class="line" data-screen-row="22" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="syntax--keyword syntax--control syntax--repeat syntax--python" style="box-sizing:border-box;color:#c678dd">for</span> location <span class="syntax--keyword syntax--operator syntax--logical syntax--python" style="box-sizing:border-box;color:#c678dd">in</span> <span class="syntax--variable syntax--other syntax--object syntax--python" style="box-sizing:border-box;color:#e06c75">soup</span><span class="syntax--meta syntax--method-call syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--punctuation syntax--separator syntax--method syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--entity syntax--name syntax--function syntax--python" style="box-sizing:border-box;color:#61afef">find_all</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">(</span><span class="syntax--meta syntax--method-call syntax--arguments syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--string syntax--quoted syntax--double syntax--single-line syntax--python" style="box-sizing:border-box;color:#98c379"><span class="syntax--punctuation syntax--definition syntax--string syntax--begin syntax--python" style="box-sizing:border-box;color:#98c379">"</span>location<span class="syntax--punctuation syntax--definition syntax--string syntax--end syntax--python" style="box-sizing:border-box;color:#98c379">"</span></span></span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">)</span></span>:</span></span></div> <div class="line" data-screen-row="23" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="leading-whitespace" style="box-sizing:border-box"> </span>loc <span class="syntax--keyword syntax--operator syntax--assignment syntax--python" style="box-sizing:border-box;color:#c678dd">=</span> <span class="syntax--variable syntax--other syntax--object syntax--python" style="box-sizing:border-box;color:#e06c75">location</span><span class="syntax--meta syntax--method-call syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--punctuation syntax--separator syntax--method syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--entity syntax--name syntax--function syntax--python" style="box-sizing:border-box;color:#61afef">find</span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">(</span><span class="syntax--meta syntax--method-call syntax--arguments syntax--python" style="box-sizing:border-box;color:#abb2bf"><span class="syntax--string syntax--quoted syntax--double syntax--single-line syntax--python" style="box-sizing:border-box;color:#98c379"><span class="syntax--punctuation syntax--definition syntax--string syntax--begin syntax--python" style="box-sizing:border-box;color:#98c379">"</span>city<span class="syntax--punctuation syntax--definition syntax--string syntax--end syntax--python" style="box-sizing:border-box;color:#98c379">"</span></span></span><span class="syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--python" style="box-sizing:border-box">)</span></span><span class="syntax--punctuation syntax--separator syntax--property syntax--period syntax--python" style="box-sizing:border-box">.</span><span class="syntax--variable syntax--other syntax--property syntax--python" style="box-sizing:border-box;color:#e06c75">string</span></span></span></div> </div> <div style="box-sizing:border-box;contain:layout style;position:absolute;height:38px;width:819px;transform:translateY(456px)"> <div class="line" data-screen-row="24" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"><span class="syntax--source syntax--python" style="box-sizing:border-box"><span class="leading-whitespace" style="box-sizing:border-box"> </span><span class="syntax--keyword syntax--other syntax--python" style="box-sizing:border-box;color:#c678dd">print</span>(loc)</span></span></div> <div class="line" data-screen-row="25" style="box-sizing:border-box;white-space:pre;contain:layout"><span style="box-sizing:border-box"></span></div> </div> <div class="cursors" style="box-sizing:border-box;position:absolute;contain:strict;z-index:1;width:819px;height:569px;pointer-events:none;user-select:none"><input class="hidden-input" tabindex="-1" style="box-sizing:border-box;color:inherit;font:inherit;margin:0px;position:absolute;width:1px;height:19px;top:504px;left:108px;opacity:0;padding:0px;border:0px" type="text" /></div> </div> <div style="box-sizing:border-box;contain:strict;position:absolute;visibility:hidden;width:819px"></div> <div class="line dummy" style="box-sizing:border-box;white-space:pre;contain:layout;position:absolute;visibility:hidden"><span style="box-sizing:border-box"></span><span style="box-sizing:border-box"></span><span style="box-sizing:border-box"></span><span style="box-sizing:border-box"></span></div> </div> <div class="vertical-scrollbar" style="box-sizing:border-box;position:absolute;contain:content;z-index:1;will-change:transform;visibility:hidden;right:0px;top:0px;bottom:10px;width:15px;overflow:hidden auto;cursor:default"> <div style="box-sizing:border-box;width:15px;height:569px"></div> </div> <div class="horizontal-scrollbar" style="box-sizing:border-box;position:absolute;contain:content;z-index:1;will-change:transform;visibility:hidden;bottom:0px;left:0px;right:10px;height:15px;overflow:auto hidden;cursor:default"> <div style="box-sizing:border-box;height:15px;width:819px"></div> </div> <div class="scrollbar-corner" style="box-sizing:border-box;position:absolute;height:20px;width:20px;bottom:0px;right:0px;overflow:scroll"></div> <div is="wrap-guide" class="wrap-guide-container" style="box-sizing:border-box;display:block"> <div class="wrap-guide" style="box-sizing:border-box;height:579px;width:1px;z-index:3;position:absolute;top:0px;background-color:rgba(171, 178, 191, 0.15);transform:translateZ(0px);pointer-events:none;left:571px"></div> </div> </div> </div> </atom-text-editor>

<atom-panel-container class="left" style="box-sizing:border-box;display:flex;justify-content:flex-end;color:#9da5b4;font-family:system-ui;font-size:12px;background-color:#21252b"><atom-dock class="left" style="box-sizing:border-box;display:flex;position:relative"></atom-dock></atom-panel-container><atom-workspace-axis class="vertical" style="box-sizing:border-box;position:relative;display:flex;flex:1 1 0%;flex-direction:column;min-width:0px;min-height:0px;color:#9da5b4;font-family:system-ui;font-size:12px;background-color:#21252b"><atom-panel-container class="top" style="box-sizing:border-box"></atom-panel-container><atom-pane-container class="panes" style="box-sizing:border-box;position:relative;display:flex;flex:1 1 0%;min-width:0px;min-height:0px"><atom-pane class="pane active" tabindex="-1" data-active-item-name="section4-1.py" data-active-item-path="C:\section4\section4-1.py" style="box-sizing:border-box;position:relative;display:flex;flex:1 1 0%;flex-direction:column;overflow:visible;min-width:0px;min-height:0px;border-right:none;border-bottom:1px solid #181a1f"></atom-pane></atom-pane-container><atom-panel-container class="bottom" style="box-sizing:border-box"><atom-panel class="bottom tool-panel panel-bottom" style="box-sizing:border-box;display:block;position:relative;border-bottom:1px solid #181a1f;border-right:1px solid #181a1f"></atom-panel></atom-panel-container></atom-workspace-axis>

Python - section4-1.py:26
Traceback (most recent call last):
  File "C:\section4\section4-1.py", line 19, in <module>
    xml = open(savename, 'r', encoding="utf-8").read()
  File "C:\Users\user\anaconda3\envs\section4\lib\codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 118: invalid start byte
[Finished in 0.152s]

답변 3

·

답변을 작성해보세요.

0

MIKE.aeon님의 프로필

MIKE.aeon

2021.02.22

파일 읽으실때, 원본파일을 보시고 euc-kr 이면 아래 처럼 인코딩을 수정하시면 됩니다.

xml = open(savename, 'r', encoding='euc-kr').read()

같은 사이트인데, url  주소에 따라서 euc-kr 인곳도 있고, utf-8 인곳도 있습니다.

0

안녕하세요.

현재 아래 주소가 변경된 것 같은데 확인 한 번 해보겠습니다.

http://www.weather.go.kr/weather/lifenindustry/sevice_rss.jsp

0

지소라님의 프로필

지소라

질문자

2020.04.28

import sys

import io

import urllib.request as req

from bs4 import BeautifulSoup

import os.path  #os.path 내에는 경로반환, 경로추출 등 파일/디렉토리 경로와 관련된 많은 함수를 제공해준다.

sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')

sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')

#다운로드 urll

url = "http://www.weather.go.kr/weather/lifenindustry/sevice_rss.jsp"

savename = "c:/section4/forecast.xml"

if not os.path.exists(savename):

    req.urlretrieve(url, savename)

    #BeautifulSoup 파싱

xml = open(savename, 'r', encoding="utf-8").read()

soup = BeautifulSoup(xml, 'html.parser')

    #지역확인

for location in soup.find_all("location"):

    loc = location.find("city").string

    print(loc)

이렇게 적었어요