Python json import 'module' object has no attribute 'loads'

5.2k Views Asked by At

I'm using PyScripter on Windows with Python 2.7.3 and I'm trying to import json. It seems to work if I use the interpreter directly, but when saved in a file and run I get 'module' object has no attribute 'loads'.

import json

j = '{"one": 1, "numbers": [1, 2, 3.5]}'

x = json.loads(j)

Interpreter for x returns, {u'numbers': [1, 2, 3.5], u'one': 1}

I'm fairly new to Python so I'm sorry if this is an idiotic question. Many thanks

0

There are 0 best solutions below