Что-то у меня разрыв шаблона случился. Как так?
#!/usr/bin/env python3.4 # -*- coding: utf-8 -*- import json json_string = '{"first_name": "Guido", "last_name":"Rossum"}' parsed_json = json.loads(json_string) print(parsed_json['first_name'])
/usr/bin/python-wrapper /home/fil/codding/json.pyВывод в SublimeText и PyCharm одинаковый.
Traceback (most recent call last):
File “~/codding/json.py”, line 3, in <module>
import json
File “~/codding/json.py”, line 5, in <module>
parsed_json = json.loads(json_string)
AttributeError: ‘module’ object has no attribute ‘loads’
Process finished with exit code 1
При этом из консоли все работает:
Python 3.4.3 (default, Apr 9 2016, 09:10:42) [GCC 4.9.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import json >>> json_string = '{"first_name": "Guido", "last_name":"Rossum"}' >>> parsed_json = json.loads(json_string) >>> print(parsed_json['first_name']) Guido
Спасибо.