Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using json #5

Open
imgarylai opened this issue Aug 18, 2013 · 0 comments
Open

Using json #5

imgarylai opened this issue Aug 18, 2013 · 0 comments
Assignees

Comments

@imgarylai
Copy link
Contributor

目前parse的資料,可以用python內建的dict來存取,因為dict也是key : value的方式存取資料,跟json很像
ex:

  data = {}
  for i in range (1,len(result)):
    for j in range (0 , len( result[i]) ):
      key = re.sub(' +', ' ', result[0][j])
      value = re.sub(' +', ' ', result[i][j])
      data[key] = value
      print data

存好的資料用python內建的json模組就可以把dict轉成json了
ex:

json.dumps(data)

http://docs.python.org/2/library/json.html

我遇到的問題是:python的編碼是個大麻煩,在parse資料時好像已經編碼過一次了,於是我在這邊print 出來的data會是我看不懂的地方,可能還要麻煩 @Lee-W 看看要怎麼能夠克服編碼的問題

@ghost ghost assigned Lee-W Aug 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants