Python Data Type Conversion
Python에서 Data Type을 변화 시키는거 ex) int -> str , str -> int
이렇게 x = 100 (int) 값을 conversion 해주면 문제없이 print out 되는걸 볼 수 있음.
List[]
그리고 리스트는 튜플과는 다르게, 안의 내용을 수정 가능하다
Dictionary {}
Key , Value를 가진 자료형
ipAddress = {} Dictionary
ipAddress["#Key Value"] = "#value you want to chagne" 해서 벨류 조정 가능
위와 같은 방식으로 뒤에 append 도 가능
"Rtr-a" in ipAddress 라는 명령어 같이 "#" Key in "Dictionary" 명령어로 딕셔너리 값 확인 가능
Input() 함수
input 함수로 사용자에게 인풋을 받을수 있음
문자열을 붙여주는 작업을, CONCATENATE 라고함
참고로 input 함수 써서 받아온 데이터의 자료형은 String 임 (아무거나 써도 다 출력 스트링으로 함)
IF문
indentation(들여쓴자리), 즉 띄어쓰기 기준으로 어느 문에 종속 되는지 표시
input 함수 사용, if 문 에서 다른 print 문장 출력
Voice 일 경우, CoS (Class of Service)의 값은 '5'가 되어야 하고, DSCP 값은 '46' 이여야함
DSCP : Differentiated Services Code Point (DSCP) is a means of classifying and managing network traffic and of providing quality of service (QoS) in modern Layer 3 IP networks. It uses the 6-bit Differentiated Services (DS) field in the IP header for the purpose of packet classification. Differentiated services (DiffServ) is a computer networking architecture that specifies a simple and scalable mechanism for classifying and managing network traffic and providing quality of service (QoS) on modern IP networks.
COS : Class of Service (CoS) is a way of managing traffic in a network by grouping similar types of traffic -- such as email, streaming video, voice over IP and large document file transfer -- together and treating each type as a class with its own level of network service priority.
For / While (Loop 문)
어떤걸 계속해서 반복하게 만드는 문법
보통 List[] 에서 For 이나 While Loop 문을 돌려서 순서대로 작업 하는 식으로 많이 함
While 문
while 같은 경우 어떤 명령어 묶음을 반복 하는데 사용, 근데 for 이랑 거의 비슷 함
1 부터 사용자가 입력한 숫자 까지 카운트를 해보자
while은 while다음 나오는 조건이 참이면 항상 실행 하게 됨
사용자는 x를 넣었고, while 조건, x 보다 작거나 같아 질때 까지 y를 계속 출력하고 마지막에 1을 더하는 스크립트
File Access
외부 파일들을 읽어나 쓰는 작업
네트워크 엔지니어들은 특히 이런 작업들을 많이 함
with open('inventory.txt' , 'r') as file <-- 이렇게 쓰면됨
객체 사이에 줄이 들어가서 이거 보기 싫으니까 strip을 써서 빈칸을 지워보자
그럼 이번에는 txt 파일에 data를 집어 넣어보자
'r' Read 대신 'a' Append 써서 그냥 값만 붙이기
new_item 이라는 변수에 input 함수 사용 -> 사용자가 입력하는 값 받아오기
new_item 즉 input 함수에 exit가 쳐지면 break 써서 while loop 탈출
'Networking > Network General (Anything)' 카테고리의 다른 글
CCNP Part 2 - 4 (0) | 2022.01.07 |
---|---|
CCNP Part 2 - 3 (0) | 2022.01.05 |
CCNP Part 2 - 1 (0) | 2022.01.04 |
Network Engineer Interview Questions (0) | 2021.11.18 |
CCNP Dump Study - 1 (0) | 2021.11.09 |