iN THIS, I'm trying to get group1 and group2 to be part of data. " string = response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/h1/span[2]/text()').get()

 if string:
 pattern = r'^(\D+)(\d+)\s'
 match = re.match(pattern, string)
 if match:
 group1 = match.group(1)
 group2 = match.group(2)
 print(group1, group2)
 else:
 print("No match found")
 else:
 print("String is None")

 data = {
 'url': response.url,
 'Profile Image': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/aside[1]/div/div/a/img/@src').get(),
 'Username': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/h1/span[1]/text()').get(),
 'Age': group1,
 'Gender': group2,
 'City 1 URL': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/p/span[1]/a/@href').get(),
 'City 1 Text': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/p/span[1]/a/text()').get(),
 'Area URL': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/p/span[2]/a/@href').get(),
 'Area Text': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/p/span[2]/a/text()').get(),
 'Country URL': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/p/span[3]/a/@href').get(),
 'Country Text': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/p/span[3]/a/text()').get(),
 'Roles': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[3]/div[5]/div[2]/div[1]/div[2]/div[2]/text()').get(),
 'Orientation': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[3]/div[5]/div[2]/div[2]/div[2]/div[2]/span/text()').get(),
 'Active' : response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[3]/div[5]/div[2]/div[3]/div[2]/div[2]/text()').get(),
 'Looking For' : response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[3]/div[5]/div[2]/div[4]/div[2]/div[2]/text()').get(),
 'About' : response.xpath('/html/body/div[3]/div/div[2]/div/div[2]/div/main/div/div[1]/div/text()').get(),
 'Into' : response.xpath('/html/body/div[3]/div/div[2]/div/div[2]/div/main/div/div[4]/div/div/div/text()').get(),
 'Groups' : response.xpath('/html/body/div[3]/div/div[2]/div/div[2]/div/aside[1]/div/div[3]/text()').get()
 }
" but I got UnboundLocalError: cannot access local variable 'group1' where it is not associated with a value
String is None
그룹1과 그룹2를 데이터의 일부로 가져 오려고합니다. " string = response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/h1/span[2]/text()').get() if 문자열: pattern = r'^(\D+)(\d+)\s' match = re.match(패턴, 문자열) if match: group1 = match.group(1) group2 = match.group(2) print(group1, group2) else: print("일치하는 항목 없음") else: print("문자열이 없음") data = { 'url': response.url, '프로필 이미지': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/aside[1]/div/div/a/img/@src').get(), 'Username': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/h1/span[1]/text()').get(), 'Age': group1, '성별': group2, 'City 1 URL': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/p/span[1]/a/@href').get(), '도시 1 텍스트': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/p/span[1]/a/text()').get(), '영역 URL': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/p/span[2]/a/@href').get(), '영역 텍스트': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/p/span[2]/a/text()').get(), '국가 URL': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/p/span[3]/a/@href').get(), '국가 텍스트': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[1]/div[2]/p/span[3]/a/text()').get(), '국가': '국가').get(), 'Roles': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[3]/div[5]/div[2]/div[2]/div[1]/div[2]/div[2]/text()').get(), '오리엔테이션': response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[3]/div[5]/div[2]/div[2]/div[2]/div[2]/span/text()').get(), '방향', 'Active' : response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[3]/div[5]/div[2]/div[3]/div[2]/div[2]/text()').get(), 'Active' : '/html/body/div[3]/div/div[2]/div/div[2]/text(), 'Looking For' : response.xpath('/html/body/div[3]/div/div[2]/div/header[1]/div/div[1]/main/div/div[3]/div[5]/div[2]/div[4]/div[2]/div[2]/text()').get(), 'About' : response.xpath('/html/body/div[3]/div/div[2]/div/div[2]/div/main/div/div[1]/div/text()').get(), 'Into' : response.xpath('/html/body/div[3]/div/div[2]/div/div[2]/div/main/div/div[4]/div/div/div/text()').get(), 'Groups' : response.xpath('/html/body/div[3]/div/div[2]/div/div[2]/div/aside[1]/div/div[3]/text()').get() }"를 호출했지만 UnboundLocalError: 값과 연결되지 않은 지역 변수 'group1'에 액세스할 수 없습니다.문자열이 없음