Python: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

后端 未结 3 574
梦如初夏
梦如初夏 2021-01-15 04:11

I am fetching data from a catalog and it\'s giving data in bytes format.

Bytes data:

b\'\\x80\\x00\\x00\\x00\\n\\x00\\x00%\\x83\\xa0\\x08\\x01\\x00\\         


        
3条回答
  •  一向
    一向 (楼主)
    2021-01-15 04:23

    For this encoding error

    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
    

    or other like that, you just have to open the database file with .json extension and change the encoding to UTF-8 (for exemple in VScode, you can change it in right-bottom nav-bar) and save the file...

    Now run

     $ git status
    

    you'll have something like this result

     On branch master
     Changes not staged for commit:
       (use "git add ..." to update what will be committed)
       (use "git restore ..." to discard changes in working directory)
            modified:   store/dumps/store.json
       (use "git add ..." to include in what will be committed)
            .gitignore
    
     no changes added to commit (use "git add" and/or "git commit -a")
    

    or something like this one

    On branch master
    Changes to be committed:
      (use "git restore --staged ..." to unstage)
            modified:   store/dumps/store.json
    Untracked files:
      (use "git add ..." to include in what will be committed)
            .gitignore
    

    for the first case, you just have to do this one

    $ git add store/dumps/
    

    the second case don't need this previous part...

    Now, for the two cases, you have to commit the changes with

    $ git commit -m "launching to production"
    

    the console will return you a message informed you for the adds and changes...

    You have to build log for the app again with

    $ git push heroku master
    

    (for heroku users)

    after the build, you just have to load the database again with

    heroku run python manage.py loaddata store/dumps/store.json
    

    it will install the objects./.

    excuses for my english level !!!

提交回复
热议问题