Skip to content

Commit

Permalink
Improve parse area id
Browse files Browse the repository at this point in the history
  • Loading branch information
tychxn committed Jan 28, 2020
1 parent 5c47a79 commit 1191bf8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions util.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import json
import os
import re
import time
import json
from base64 import b64encode
from random import shuffle

Expand Down Expand Up @@ -108,7 +109,12 @@ def list_to_str(l):
return '[%s]' % ','.join(l)


def parse_area_id(area_id='12_904_3375'):
area = list(area_id.split('_'))
def parse_area_id(area_id):
"""
解析地区id
:param area_id: 地区id字符串(使用 _ 或 - 进行分割),如 12_904_3375 或 12-904-3375
:return:
"""
area = re.split('_|-', area_id)
area.extend((4 - len(area)) * ['0'])
return area

0 comments on commit 1191bf8

Please sign in to comment.