-2
pref_network_find = re.findall('(\S+\s+255.255.255\S+)',data)
prefixes = '\n'.join(['ip ip-prefix VSP_NETWORKS index permit ' + q for q in pref_network_find])
모두 안녕하세요! 나는이 간단한 코드 및 출력이 있습니다목록 출력에 특정 단계가있는 변수 추가
ip ip-prefix VSP_NETWORKS index permit 10.185.97.160 255.255.255.224
ip ip-prefix VSP_NETWORKS index permit 11.185.45.64 255.255.255.240
ip ip-prefix VSP_NETWORKS index permit 55.110.192.24 255.255.255.248
ip ip-prefix VSP_NETWORKS index permit 55.110.203.0 255.255.255.0
그래서, 내가 필요하면 자동으로 10 단계로 번호를 할당 목록의 각 행에 변수를 추가하는 것입니다. 목록의 행 수에 바인드 된 변수 여야합니다.
마지막으로, 출력은 다음과 같이해야합니다 : 쉽게 읽을
ip ip-prefix VSP_NETWORKS index 10 permit 10.185.97.160 255.255.255.224
ip ip-prefix VSP_NETWORKS index 20 permit 11.185.45.64 255.255.255.240
ip ip-prefix VSP_NETWORKS index 30 permit 55.110.192.24 255.255.255.248
ip ip-prefix VSP_NETWORKS index 40 permit 55.110.203.0 255.255.255.0
에 열거 0을 추가하여이 문제를 단순화하고 시작할 수 있습니다. 너를 그만 두는게 뭐야? 힌트 :'zip'을 사용하십시오. –
나는 가난한 경험으로 나를 막을 수 있다고 생각한다. – Dover