擅长:python、mysql、java
<p>如果您有更多的IP(10+),那么最好先将它们存储到excel的某个列中,然后将它们的范围用作数据验证“源”即公式1。在</p>
<pre><code>from openpyxl.worksheet.datavalidation import DataValidation
wb = Workbook()
ws = wb.create_sheet('New Sheet')
for number in range(1,100): #Generates 99 "ip" address in the Column A;
ws['A{}'.format(number)].value= "192.168.1.{}".format(number)
data_val = DataValidation(type="list",formula1='=$A:$A') #You can change =$A:$A with a smaller range like =A1:A9
ws.add_data_validation(data_val)
data_val.add(ws["B1"]) #If you go to the cell B1 you will find a drop down list with all the values from the column A
wb.save('Test.xlsx')
</code></pre>
<p>更多信息:<a href="https://openpyxl.readthedocs.io/en/2.5/validation.html" rel="noreferrer">https://openpyxl.readthedocs.io/en/2.5/validation.html</a></p>