尝试阅读Excel,但不确定如何编写代码以满足要求。 来自Excel的人希望以这种方式加入俱乐部。
ACL_PREFIX_LIST_NAME = CE1_OUT
DEFAULT_ACTION =前进
PERMIT_PREFIX = 10.10.10.1/32,10.10.10.11/32
DEBY_PREFIX = 10.10.10.2/32
将上述信息传递给某些函数或类。
import xlrd
import xlwt
import pandas as pd
import numpy as np
existing_excel_file = 'std_excel_v2.xlsx'
df_acl = pd.read_excel(existing_excel_file, sheet_name='access-list')
acl_list = []
for m in range(0, len(df_acl['ACL_PREFIX_LIST_NAME'])):
if pd.isnull(df_acl['ACL_PREFIX_LIST_NAME'][m]):
pass
else:
acl_list.append((df_acl['ACL_PREFIX_LIST_NAME'][m]))
for acl in acl_list:
default_action = ''
permit_list = []
deny_list = []
for m in range(0, len(df_acl['ACL_PREFIX_LIST_NAME'])):
if df_acl['ACL_PREFIX_LIST_NAME'][m] == acl:
default_action = df_acl['DEFAULT_ACTION'][m]
for n in range(0,len(df_acl['PERMIT-DENY'])):
print(df_acl['PERMIT-DENY'][n])