<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>yuheiomori0718</author_name>
  <author_url>https://blog.hatena.ne.jp/yuheiomori0718/</author_url>
  <blog_title>メモ置き場</blog_title>
  <blog_url>https://y0m0r.hateblo.jp/</blog_url>
  <categories>
    <anon>python</anon>
  </categories>
  <description>pythonで仕事してるとちょいちょいUnicodeEncodeErrorとかUnicodeDecodeErrorに遭遇します。 最初ははまると思うんで原因と対応方法についてメモしておきます。python2系の話です。 まずstr型とunicode型の違い pythonのstrはバイト文字列、unicodeはユニコード文字列です # coding=utf-8 s = &quot;あ&quot; print [s] # =&gt; ['\xe3\x81\x82'] u = u&quot;あ&quot; print [u] # =&gt; [u'\u3042'] len関数は、str型に対して使うとバイト数を返すので文字数のカウントには使えません …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fy0m0r.hateblo.jp%2Fentry%2F20121208%2F1354979490&quot; title=&quot;Pythonのencodeとdecode、strとunicode - メモ置き場&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2012-12-08 00:11:30</published>
  <title>Pythonのencodeとdecode、strとunicode</title>
  <type>rich</type>
  <url>https://y0m0r.hateblo.jp/entry/20121208/1354979490</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
