파이썬(156)
-
Invalid HTTP_HOST header: '192.168.0.3'. You may need to add '192.168.0.10' to ALLOWED_HOSTS.
setting.py에 아래와 같이 서비스하려는 IP 등록해야 함 ALLOWED_HOSTS = ['localhost','127.0.0.1','192.168.0.10'] 서비스하려는 IP로 시작 python manage.py runserver 192.168.0.10:80
2021.03.27 -
Django union
unionedImages = Trained_Image.objects.all().values_list('prefix').union(Image.objects.all().values_list('prefix')) for unionedImage in unionedImages : print(unionedImage) 결과 ('./aaa/aa/96',) ('./bbb/bb/97',)
2021.03.27 -
Django filter 정규식
boxes = Trained_Box.objects.filter(char__iregex=r'[0-9]').exclude(status='excepted')
2021.03.27 -
Django filter Max 구하기
from django.db.models import Max name = Tested_Data.objects.filter(name__contains=lang).aggregate(name=Max('name')) print(name) print(name['name']) 결과 {'name': './aaa/aa/222'} ./aaa/aa/222
2021.03.27 -
파일 처리
images = Trained_Image.objects.all() for i,image in enumerate(images) : fileName,ext = os.path.splitext(image.file) dir = os.path.dirname(image.file) oldFile = image.file image.file = '%s/%s%s' %(dir,i,ext) image.box_file = '%s/%s.box' %(dir,i) image.tr_file = '%s/%s.tr' %(dir,i) image.prefix = '%s/%s' %(dir,i) image.save() print(oldFile,image.file,image.box_file,image.tr_file,image.prefix) os.r..
2021.03.27 -
정규식 사용하기
데이터 형식 : 592/? ((9003,4707),(9012,4719)) import re p = re.search(' (\d+)/(.) \(\((\d+),(\d+)\),\((\d+),(\d+)',line) print(p.groups()) boxData = p.groups() 데이터 형식 : /aaa/bbb/99 max = '/aaa/bbb/99' max = re.search('/(\d+)$',max) print(max) print(max.groups()) print(max.group(0)) print(max.group(1)) 결과 ('99',) /99 99
2021.03.13