본문 바로가기
반응형

python28

복수개의 값 리스트에서 지우기 (None, multiple data remove in list) 네트워크 장비에 접속해 그 출력을 파싱할 때 자주 필요한 기능으로 추후 빨리 찾기 위해서 기록해 놓는다. I use this feature really frequently when parsing network devices console's output. Basically, this post is for myself. 1. None 값을 지우기 (Remove None values in list) -> filter 함수 이용 (Using filter function) a = ['''TenGigabitEthernet1/13 unassigned YES TFTP administratively down down TenGigabitEthernet1/14 unassigned YES TFTP administrative.. 2020. 9. 11.
Basic usage exchangelib (MS Exchange) MS Exchange is a intergrated software for email, calendar, tasks, and etc. There are many features that we can use. But this time, I introduce a basic usage of exchagelib with Python. Especially sending an email with an attachment. from exchangelib import * credentials = Credentials(username='yourusername', password='yourpassword') account = Account(primary_smtp_address='youremailaddress', crede.. 2020. 8. 1.
Openpyxl - Make a report template Let's create a report template as shown above. import datetime import openpyxl from openpyxl.styles import Border, Side, Font, Alignment, PatternFill def createExcelFile(): # Excel File Creation nowDate = 'Report Date: ' + str(datetime.datetime.now().strftime('%Y-%m-%d')) wb = openpyxl.Workbook() ws = wb.active ws.title = 'SNMP Community' # Pretty display for the File font = Font(bold=True) alig.. 2020. 7. 30.
How to get a dict key in the list Example: interfaceList = [{"Gi 0/1" : "Switch 1"}, {"Gi 0/2" : "Switch 2"}] I want to get soley a str-type key from the list to look up a list of dict, which are Gi 0/1 and Gi 0/2. But, if I iterate and print the interfaceList and using keys() functions for elem in interfaceList: print(elem.keys()) I get a dict_keys-type key instead like the right below output. [Output] dict_keys(['Gi 0/1']) dic.. 2020. 6. 13.
반응형