Найти - Пользователи
Полная версия: Ошибка TypeError: 'int' object has no attribute '__getitem__'
Начало » Python для новичков » Ошибка TypeError: 'int' object has no attribute '__getitem__'
1
arizona
Здраствуйте,нужна помощь, нужно вытащить инфирмацию по ключевому слову , но появляется ошибка “ TypeError: ‘int’ object has no attribute ‘__getitem__’”
import urllib2
import ast 
def url(): 
  url = "https://api.vk.com/method/wall.get?owner_id=-28689448&domain=http://vk.com/stancee&offset=2&count=1&filter=owner&extended=0&fields=0"
  response = urllib2.urlopen(url) 
  text = response.read() 
  post_info = ast.literal_eval(text) 
  return post_info['response'][0]['attachments'] 
music = url()
py.user.next
Используй json, а не ast.
arizona
py.user.next
можешь привести пример работы с json?
JOHN_16
arizona
ага
import json
json.loads(value)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB