{"action":"created","issue":{"url":"https://api.github.com/repos/sunpudding/python/issues/18","repository_url":"https://api.github.com/repos/sunpudding/python","labels_url":"https://api.github.com/repos/sunpudding/python/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/sunpudding/python/issues/18/comments","events_url":"https://api.github.com/repos/sunpudding/python/issues/18/events","html_url":"https://github.com/sunpudding/python/issues/18","id":348990663,"node_id":"MDU6SXNzdWUzNDg5OTA2NjM=","number":18,"title":"需要重新审视代码，精简代码","user":{"login":"peter-way","id":41514055,"node_id":"MDQ6VXNlcjQxNTE0MDU1","avatar_url":"https://avatars1.githubusercontent.com/u/41514055?v=4","gravatar_id":"","url":"https://api.github.com/users/peter-way","html_url":"https://github.com/peter-way","followers_url":"https://api.github.com/users/peter-way/followers","following_url":"https://api.github.com/users/peter-way/following{/other_user}","gists_url":"https://api.github.com/users/peter-way/gists{/gist_id}","starred_url":"https://api.github.com/users/peter-way/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peter-way/subscriptions","organizations_url":"https://api.github.com/users/peter-way/orgs","repos_url":"https://api.github.com/users/peter-way/repos","events_url":"https://api.github.com/users/peter-way/events{/privacy}","received_events_url":"https://api.github.com/users/peter-way/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-09T06:11:01Z","updated_at":"2018-08-10T10:51:13Z","closed_at":null,"author_association":"NONE","body":"例如\r\n```\r\n    @staticmethod\r\n    def is_ipv4(data):\r\n        \"\"\"传入数据帧，对数据帧的以太网层的type字段进行判断，若为IPV4\r\n\r\n        返回TRUE，反之则为FALSE\"\"\"\r\n        ethernet_type = struct.unpack('H', data[12:14])[0]\r\n        if ethernet_type == 8:\r\n            return True\r\n        else:\r\n            return False\r\n```\r\n\r\n这完全可以一行代码搞定\r\n```\r\nreturn struct.unpack('H', data[12:14])[0]  == 8\r\n```"},"comment":{"url":"https://api.github.com/repos/sunpudding/python/issues/comments/412048515","html_url":"https://github.com/sunpudding/python/issues/18#issuecomment-412048515","issue_url":"https://api.github.com/repos/sunpudding/python/issues/18","id":412048515,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjA0ODUxNQ==","user":{"login":"sunpudding","id":37238869,"node_id":"MDQ6VXNlcjM3MjM4ODY5","avatar_url":"https://avatars1.githubusercontent.com/u/37238869?v=4","gravatar_id":"","url":"https://api.github.com/users/sunpudding","html_url":"https://github.com/sunpudding","followers_url":"https://api.github.com/users/sunpudding/followers","following_url":"https://api.github.com/users/sunpudding/following{/other_user}","gists_url":"https://api.github.com/users/sunpudding/gists{/gist_id}","starred_url":"https://api.github.com/users/sunpudding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunpudding/subscriptions","organizations_url":"https://api.github.com/users/sunpudding/orgs","repos_url":"https://api.github.com/users/sunpudding/repos","events_url":"https://api.github.com/users/sunpudding/events{/privacy}","received_events_url":"https://api.github.com/users/sunpudding/received_events","type":"User","site_admin":false},"created_at":"2018-08-10T10:51:13Z","updated_at":"2018-08-10T10:51:13Z","author_association":"OWNER","body":"已经按照大神的指示，将冗余的代码删除，精简处理\r\n```\r\n    @staticmethod\r\n    def is_tcp(data):\r\n        \"\"\"传入数据帧，对数据帧的ip的protocol字段进行判断，若为tcp协议\r\n\r\n        返回TRUE，反之则为FALSE\"\"\"\r\n        return struct.unpack('b', data[23:24])[0] == 6\r\n\r\n    @staticmethod\r\n    def is_ipv4(data):\r\n        \"\"\"传入数据帧，对数据帧的以太网层的type字段进行判断，若为IPV4\r\n\r\n        返回TRUE，反之则为FALSE\"\"\"\r\n        return struct.unpack('H', data[12:14])[0] == 8\r\n```"}}
{"actor":{"display_login":"sunpudding"}}