本文整理汇总了Python中models.Place.blockno方法的典型用法代码示例。如果您正苦于以下问题:Python Place.blockno方法的具体用法?Python Place.blockno怎么用?Python Place.blockno使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Place
的用法示例。
在下文中一共展示了Place.blockno方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadxlsdata
# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import blockno [as 别名]
def loadxlsdata(args):
import settings
import re
from places.models import Place
filepath = settings.XLSDIR + '\\xls.dat'
lines = [line.strip() for line in open(filepath)]
howmany = 0 if args.howmany <= 0 else args.howmany
reobj = re.compile(r"\d+-\d+-(?P<districtno>\d+)")
linecount = 0
for line in lines:
if line and line[0].isalpha():
# get district number from this string
match = reobj.search(line)
if not match:
raise Exception("Failed to find expected district number")
districtno = int(match.group("districtno"))
continue
elif line and line[0] == '{':
pass
else:
continue
rec = eval(line)
p = Place()
p.provinceno = rec['provinceno']
p.districtno = districtno
p.cantonno = rec['districtno']
p.territoryno = rec['territoryno']
p.blockno = rec['blockno'] if 'blockno' in rec else None
p.houseno = rec['houseno']
p.districtname = rec['districtname']
p.directions = rec['directions']
p.notes = rec['notes']
p.save()
linecount += 1
if linecount and linecount == howmany:
break