Reputation: 51039
The very same code
A=b'["c1006","c1007"]'
json.loads(A)
works in Python console, but doesn't work in Jupyter notebook, saying
TypeError: the JSON object must be str, not 'bytes'
Why and how to fix / write portable?
I am using Python 3.x on Linux:
(py36) dims@calculon:~$ python
Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> A= b'["c1006","c1007"]'
>>> json.loads(A)
['c1006', 'c1007']
Upvotes: 0
Views: 211
Reputation: 1932
Works for me:
The version of the notebook server is: 5.6.0
The server is running on this version of Python:
Python 3.6.6 |Anaconda custom (64-bit)| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)]
A=b'["c1006","c1007"]'
json.loads(A)
['c1006', 'c1007']
Check your version,seems to be running different python version than your anaconda has :
import sys
sys.version
Upvotes: 1