• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            sunrise

            每天不斷學(xué)習(xí),才能不斷提升自己。

              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              64 隨筆 :: 0 文章 :: 92 評(píng)論 :: 0 Trackbacks
            本來是為了省事處理數(shù)據(jù)的時(shí)候批量插入,結(jié)果插入的時(shí)候一直不能decode。
            python代碼:
            a=open(r"testdata.txt").read(20)
            print list(a)
            print '=========================================================================================='
            print list(a.decode('utf8'))
            print '=========================================================================================='
            testdata數(shù)據(jù):
            0 1 test 這件衣服設(shè)計(jì)的正好看,正是我想要的 2013/2/23 zh
            0
            2 happys 這件衣服設(shè)計(jì)的正好看,正是我想要的 2013/11/21 zh

            出現(xiàn)的錯(cuò)誤:
            ['\xef', '\xbb', '\xbf', '0', '\t', '1', '\t', 't', 'e', 's', 't', '\t', '\xe8', '\xbf', '\x99', '\xe4', '\xbb', '\xb6', '\xe8', '\xa1']
            ==========================================================================================

            Traceback (most recent call last):
            File
            "E:/designerpage/test.py", line 4, in <module>
            print list(a.decode('utf8'))
            File
            "D:\Python27\lib\encodings\utf_8.py", line 16, in decode
            return codecs.utf_8_decode(input, errors, True)
            UnicodeDecodeError:
            'utf8' codec can't decode bytes in position 18-19: unexpected end of data
            出現(xiàn)錯(cuò)誤的原因是因?yàn)閡tf8格式一般是'\xef', '\xbb', '\xbf'三個(gè)一起出現(xiàn),然后解析的,而在某處不能夠成三個(gè)一組的時(shí)候就會(huì)出現(xiàn)這樣的錯(cuò)誤。如果將20改為18則可以正常執(zhí)行。
            當(dāng)然如果是在python2.6里是可以運(yùn)行的,python2.7就會(huì)出現(xiàn)如上錯(cuò)誤。無比坑爹的bug,查了好久。
            posted on 2013-02-21 16:39 SunRise_at 閱讀(9948) 評(píng)論(2)  編輯 收藏 引用 所屬分類: python解決方案

            評(píng)論

            # re: UnicodeDecodeError: 'utf8' codec can't decode bytes in position 18-19: unexpected end of data 2013-10-16 11:01 opina
            那這個(gè)問題是怎么解決的呢?  回復(fù)  更多評(píng)論
              

            # re: UnicodeDecodeError: 'utf8' codec can't decode bytes in position 18-19: unexpected end of data 2013-10-16 11:02 opina
            Traceback (most recent call last):
            File "C:/Python25/testPaython/terry3.py", line 35, in <module>
            sheet1.write(row,1,customerid.decode('utf8'))
            File "C:\Python25\lib\encodings\utf_8.py", line 16, in decode
            return codecs.utf_8_decode(input, errors, True)
            UnicodeDecodeError: 'utf8' codec can't decode bytes in position 2-3: invalid data

            這是我報(bào)的錯(cuò)
            sheet1.write(row,1,customerid.decode('utf8'))
            這個(gè)是報(bào)錯(cuò)行,求解  回復(fù)  更多評(píng)論
              

            久久亚洲天堂| 久久精品毛片免费观看| 久久97久久97精品免视看| 99久久精品免费观看国产| 久久乐国产精品亚洲综合| 一本色综合网久久| 国产99久久久国产精免费| 亚洲欧美成人久久综合中文网 | 亚洲а∨天堂久久精品9966| 久久亚洲精品成人无码网站| 俺来也俺去啦久久综合网| 精品99久久aaa一级毛片| 中文字幕人妻色偷偷久久| 色偷偷888欧美精品久久久| 久久成人小视频| 久久精品成人免费国产片小草| 无码日韩人妻精品久久蜜桃| 午夜精品久久久久久久无码| 久久精品国产只有精品2020| 伊人伊成久久人综合网777| 久久精品国产亚洲5555| 国内精品久久久久影院免费| 亚洲色欲久久久综合网东京热| 久久国产成人精品国产成人亚洲| 精品免费tv久久久久久久| 性色欲网站人妻丰满中文久久不卡| 久久久久久毛片免费看| 精品国产热久久久福利| 99国内精品久久久久久久| 女人香蕉久久**毛片精品| 亚洲国产成人久久精品动漫| 97超级碰碰碰久久久久| 男女久久久国产一区二区三区| 97视频久久久| 中文字幕久久波多野结衣av| 久久亚洲AV无码精品色午夜 | 久久人人爽人人人人片av| 人人狠狠综合88综合久久| 久久久久国产一级毛片高清板| 精品人妻伦一二三区久久| 久久国产美女免费观看精品|