{"action":"created","issue":{"url":"https://api.github.com/repos/haoxins/mylog/issues/55","repository_url":"https://api.github.com/repos/haoxins/mylog","labels_url":"https://api.github.com/repos/haoxins/mylog/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/haoxins/mylog/issues/55/comments","events_url":"https://api.github.com/repos/haoxins/mylog/issues/55/events","html_url":"https://github.com/haoxins/mylog/issues/55","id":72676702,"number":55,"title":"[python] start notes","user":{"login":"coderhaoxin","id":2569835,"avatar_url":"https://avatars.githubusercontent.com/u/2569835?v=3","gravatar_id":"","url":"https://api.github.com/users/coderhaoxin","html_url":"https://github.com/coderhaoxin","followers_url":"https://api.github.com/users/coderhaoxin/followers","following_url":"https://api.github.com/users/coderhaoxin/following{/other_user}","gists_url":"https://api.github.com/users/coderhaoxin/gists{/gist_id}","starred_url":"https://api.github.com/users/coderhaoxin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coderhaoxin/subscriptions","organizations_url":"https://api.github.com/users/coderhaoxin/orgs","repos_url":"https://api.github.com/users/coderhaoxin/repos","events_url":"https://api.github.com/users/coderhaoxin/events{/privacy}","received_events_url":"https://api.github.com/users/coderhaoxin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/haoxins/mylog/labels/note","name":"note","color":"009800"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-05-02T17:57:44Z","updated_at":"2016-02-28T09:51:42Z","closed_at":"2015-05-02T18:00:04Z","body":"* hello\r\n\r\n```py\r\n#!/usr/bin/env python\r\n\r\nprint('hello world')\r\n\r\n# type\r\n\r\na = 123\r\nprint(type(a))\r\na = '123'\r\nprint(type(a))\r\n\r\n#\r\n\r\ns1 = (123, 'xx', 1.2)  # const\r\ns2 = [123, 'xx', 1.2]  # var\r\ns2.append(12306)\r\nprint(s1[1:], s1[:2])\r\n\r\n#\r\n\r\nprint(2**3)\r\nprint(2 in (1, 2, 3))\r\nprint(1 == 1 and '2' == '2')\r\nprint(not True)\r\n\r\n# if\r\n\r\ni = 3\r\nif i > 1:\r\n  print('i > 1')\r\n\r\nif i > 4:\r\n  print('i > 4')\r\nelif i > 3:\r\n  print('i > 3')\r\n\r\n\r\nif i > 4:\r\n  print('i > 4')\r\nelif i > 3:\r\n  print('i > 3')\r\nelse:\r\n  print('ii')\r\n\r\n# for\r\n\r\nfor i in (1, 2, 3):\r\n  print(1)\r\n\r\nfor i in range(3):\r\n  print(i)\r\n\r\nx = 6\r\nwhile x < 10:\r\n  print(x)\r\n  x = x + 1\r\n\r\n# fun\r\n\r\n\r\ndef add(a, b):\r\n  return a + b\r\n\r\nprint(add(1, 4))\r\n\r\n# oop\r\n\r\n\r\nclass User(object):\r\n  name = 'haoxin'\r\n\r\n  def __init__(self, name):\r\n    # optional\r\n    print('init')\r\n    self.name = name\r\n\r\n  def show(self):\r\n    print('name:', self.name)\r\n\r\nu = User('x')\r\nu.show()\r\nu.name = 'xxx'\r\nu.show()\r\n\r\n# dic\r\n\r\ndic = {\r\n    'name': 'haoxin',\r\n    'desc': 'haha'\r\n}\r\n\r\nfor k in dic:\r\n  print(k, dic[k])\r\n\r\ndel dic['desc']\r\n\r\nprint(dic.keys())\r\nprint(dic.values())\r\nprint(dic.items())\r\nprint(len(dic))\r\n\r\n# file\r\nf = open('hello.py', 'r')\r\nprint(f.readline())\r\nf.close()\r\n\r\n# multi add\r\n\r\n\r\ndef madd(a=1, b=2, c=3):\r\n  return a + b + c\r\n\r\nprint(madd())\r\nprint(madd(1, 2, 3))\r\nprint(madd(c=3, b=22, a=111))\r\n\r\n#\r\n\r\n\r\ndef f1(*args):\r\n  print(type(args))\r\n\r\nf1('xx', 'oo')\r\n\r\n\r\ndef f2(**args):\r\n  print(type(args))\r\n\r\nf2(name='xx', desc='oo')\r\n\r\n#\r\ns = 'http'\r\n\r\nfor i in range(0, len(s), 2):\r\n  print(s[i])\r\n\r\nfor (k, v) in enumerate(s):\r\n  print(k, v)\r\n\r\na1 = ['x1', 'x2', 'x3']\r\na2 = ['y1', 'y2', 'y3']\r\na3 = ['z1', 'z2', 'z3']\r\n\r\nfor (a, b, c) in zip(a1, a2, a3):\r\n  print(a, b, c)\r\n\r\n# generator\r\n\r\n\r\ndef gen():\r\n  yield 123\r\n  yield 456\r\n  yield 789\r\n\r\nfor i in gen():\r\n  print(i)\r\n\r\n# try\r\ntry:\r\n  print(xxoo)\r\nexcept TypeError:\r\n  print('type error')\r\nexcept NameError:\r\n  print('NameError')\r\nfinally:\r\n  print('finally')\r\n\r\ntry:\r\n  # throw exception\r\n  raise TypeError()\r\nexcept TypeError:\r\n  print('TypeError ..')\r\nfinally:\r\n  print('finally ..')\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/haoxins/mylog/issues/comments/189832548","html_url":"https://github.com/haoxins/mylog/issues/55#issuecomment-189832548","issue_url":"https://api.github.com/repos/haoxins/mylog/issues/55","id":189832548,"user":{"login":"coderhaoxin","id":2569835,"avatar_url":"https://avatars.githubusercontent.com/u/2569835?v=3","gravatar_id":"","url":"https://api.github.com/users/coderhaoxin","html_url":"https://github.com/coderhaoxin","followers_url":"https://api.github.com/users/coderhaoxin/followers","following_url":"https://api.github.com/users/coderhaoxin/following{/other_user}","gists_url":"https://api.github.com/users/coderhaoxin/gists{/gist_id}","starred_url":"https://api.github.com/users/coderhaoxin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coderhaoxin/subscriptions","organizations_url":"https://api.github.com/users/coderhaoxin/orgs","repos_url":"https://api.github.com/users/coderhaoxin/repos","events_url":"https://api.github.com/users/coderhaoxin/events{/privacy}","received_events_url":"https://api.github.com/users/coderhaoxin/received_events","type":"User","site_admin":false},"created_at":"2016-02-28T09:51:42Z","updated_at":"2016-02-28T09:51:42Z","body":"#96 python tips"}}