SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
Introduction to Python
for Network Engineer
(Basic)
Before We Start
Do you know these following languages?
´  C/C++
´  Java
´  Shell
´  Batch
´  TCL
´  Python
Python Overview
´  A script programming language
´  A high-level programming language 
´  object-oriented
´  No compilation
´  No datatype declaration
What can Python do?
Many many things which Python could do
but the only one thing we will talk about is
“ Network Automation”
Running Python: Interactively
Python is pre-installed on Linux platform
[porhai@python ~]$ python
Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> print "Hello world"
Hello world
>>>
Running Python: .py file
[porhai@python ~]$ vi khnog.py
print "hello world"
~
~
[porhai@python ~]$ python khnog.py
hello world
[porhai@python ~]$
Python VS Shell
[porhai@python ~]$ echo Hello World
Hello World
[porhai@python ~]$
>>> print "Hello world"
Hello world
>>>
Shell
Python
Python VS Shell
[porhai@python ~]$ vi khnog.sh
echo Hello World
~
[porhai@python ~]$ sh khnog.sh
Hello World
[porhai@python ~]$
Shell Python
[porhai@python ~]$ vi khnog.py
print "hello world"
~
[porhai@python ~]$ python khnog.py
hello world
[porhai@python ~]$
Python Input/Output
>>> x = raw_input("x = ")
x = 123
>>>
>>> print x
123
Python Datatypes
´  Integer (int)
´  Float (float)
´  String (str)
´  List (list)
´  Dictionary (dict)
>>> x=1
>>> type(x)
<type 'int'>
>>> x="hello"
>>> type(x)
<type 'str'>
>>>
>>> x=[1,2,3]
>>> type(x)
<type 'list'>
>>> x={'name':'porhai', 'age':22}
>>> type(x)
<type 'dict'>
>>> x=1.1
>>> type(x)
<type 'float'>
Python Modules
´  Telnetlib
´  Paramiko
´  Smtplib
´  PySNMP
Python Program Example
´  Login to Switch
´  Enter Username and Password
´  Get configuration of interface
´  Output result
Python Code
[porhai@python ~]$ vi khnog.py
import telnetlib
def open_telnet_conn(ip):
#Change exception message
try:
#Define telnet parameters
username = 'porhai'
password = 'porhai'
TELNET_PORT = 23
#Logging into device
connection = telnetlib.Telnet(ip, TELNET_PORT, TELNET_TIMEOUT)
Python Code
connection.write(username + "n")
connection.write(password + "n")
time.sleep(1)
connection.write("show run int g0/1 n")
time.sleep(1)
Output = connection.read_very_eager()
print Output
#Closing the connection
connection.close()
except IOError:
print "Input parameter error! Please check username, password
and file name."
open_telnet_conn("10.1.1.1")
Python Program Executed
[porhai@python ~]$ python khnog.py
User Access Verification
Username: porhai
Password:
S1#show run int g0/1
Building configuration...
Current configuration : 66 bytes
!
interface GigabitEthernet0/1
no switchport
no ip address
end
Reference
´  Python Language Comparison
https://www.python.org/doc/essays/comparisons/
Shell
´  Python Lesson
http://learnpythonthehardway.org/
´  Python for Network Engineers
https://pynet.twb-tech.com/
Thanks you!!!

Weitere ähnliche Inhalte

Was ist angesagt?

Compact ordered dict__k_lab_meeting_
Compact ordered dict__k_lab_meeting_Compact ordered dict__k_lab_meeting_
Compact ordered dict__k_lab_meeting_miki koganei
 
Swift 4 : Codable
Swift 4 : CodableSwift 4 : Codable
Swift 4 : CodableSeongGyu Jo
 
Wildcards, Simple Shell Programs and Shell Variables
Wildcards, Simple Shell Programs and Shell VariablesWildcards, Simple Shell Programs and Shell Variables
Wildcards, Simple Shell Programs and Shell VariablesGaurav Bisht
 
Natural Language Processing and Python
Natural Language Processing and PythonNatural Language Processing and Python
Natural Language Processing and Pythonanntp
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go ProgrammingLin Yo-An
 
The Ring programming language version 1.7 book - Part 14 of 196
The Ring programming language version 1.7 book - Part 14 of 196The Ring programming language version 1.7 book - Part 14 of 196
The Ring programming language version 1.7 book - Part 14 of 196Mahmoud Samir Fayed
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filtersbhatvijetha
 
Vim Script Programming
Vim Script ProgrammingVim Script Programming
Vim Script ProgrammingLin Yo-An
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In PythonMarwan Osman
 
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017Codemotion
 

Was ist angesagt? (20)

Compact ordered dict__k_lab_meeting_
Compact ordered dict__k_lab_meeting_Compact ordered dict__k_lab_meeting_
Compact ordered dict__k_lab_meeting_
 
Cpp lab 13_pres
Cpp lab 13_presCpp lab 13_pres
Cpp lab 13_pres
 
Python for Penetration testers
Python for Penetration testersPython for Penetration testers
Python for Penetration testers
 
Swift 4 : Codable
Swift 4 : CodableSwift 4 : Codable
Swift 4 : Codable
 
Crystal Rocks
Crystal RocksCrystal Rocks
Crystal Rocks
 
Wildcards, Simple Shell Programs and Shell Variables
Wildcards, Simple Shell Programs and Shell VariablesWildcards, Simple Shell Programs and Shell Variables
Wildcards, Simple Shell Programs and Shell Variables
 
Python build your security tools.pdf
Python build your security tools.pdfPython build your security tools.pdf
Python build your security tools.pdf
 
Natural Language Processing and Python
Natural Language Processing and PythonNatural Language Processing and Python
Natural Language Processing and Python
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
 
The Ring programming language version 1.7 book - Part 14 of 196
The Ring programming language version 1.7 book - Part 14 of 196The Ring programming language version 1.7 book - Part 14 of 196
The Ring programming language version 1.7 book - Part 14 of 196
 
Swift Study #7
Swift Study #7Swift Study #7
Swift Study #7
 
Unix - Shell Scripts
Unix - Shell ScriptsUnix - Shell Scripts
Unix - Shell Scripts
 
Clojure+ClojureScript Webapps
Clojure+ClojureScript WebappsClojure+ClojureScript Webapps
Clojure+ClojureScript Webapps
 
Basics of unix
Basics of unixBasics of unix
Basics of unix
 
Biopython
BiopythonBiopython
Biopython
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filters
 
Vim Script Programming
Vim Script ProgrammingVim Script Programming
Vim Script Programming
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
 
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
 
Workshop programs
Workshop programsWorkshop programs
Workshop programs
 

Andere mochten auch

Rapid Ring Protection Protocol (RRPP)
Rapid Ring Protection Protocol (RRPP)Rapid Ring Protection Protocol (RRPP)
Rapid Ring Protection Protocol (RRPP)KHNOG
 
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsTessa Mero
 
Bidirectional Forwarding Detection (BFD)
Bidirectional Forwarding Detection (BFD) Bidirectional Forwarding Detection (BFD)
Bidirectional Forwarding Detection (BFD) KHNOG
 
Network Mapper (NMAP)
Network Mapper (NMAP)Network Mapper (NMAP)
Network Mapper (NMAP)KHNOG
 
Policy Based Routing (PBR)
Policy Based Routing (PBR)Policy Based Routing (PBR)
Policy Based Routing (PBR)KHNOG
 
Routing Implementation - Cisco vs. Mikrotik
Routing Implementation - Cisco vs. MikrotikRouting Implementation - Cisco vs. Mikrotik
Routing Implementation - Cisco vs. MikrotikKHNOG
 
IT Service Level Agreement
IT Service Level AgreementIT Service Level Agreement
IT Service Level AgreementKHNOG
 
SIP (Session Initiation Protocol)
SIP (Session Initiation Protocol)SIP (Session Initiation Protocol)
SIP (Session Initiation Protocol)KHNOG
 
Denoising auto encoders(d a)
Denoising auto encoders(d a)Denoising auto encoders(d a)
Denoising auto encoders(d a)Tae Young Lee
 
Python Network Programming
Python Network ProgrammingPython Network Programming
Python Network ProgrammingTae Young Lee
 
Sns(social network service)
Sns(social network service)Sns(social network service)
Sns(social network service)Tae Young Lee
 
Machine learning in spam
Machine learning in spamMachine learning in spam
Machine learning in spamTae Young Lee
 
DEVNET-1001 Coding 101: How to Call REST APIs from a REST Client and Python
DEVNET-1001 Coding 101: How to Call REST APIs from a REST Client and PythonDEVNET-1001 Coding 101: How to Call REST APIs from a REST Client and Python
DEVNET-1001 Coding 101: How to Call REST APIs from a REST Client and PythonCisco DevNet
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with PythonLarry Cai
 

Andere mochten auch (16)

Rapid Ring Protection Protocol (RRPP)
Rapid Ring Protection Protocol (RRPP)Rapid Ring Protection Protocol (RRPP)
Rapid Ring Protection Protocol (RRPP)
 
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple Steps
 
Python101
Python101Python101
Python101
 
Bidirectional Forwarding Detection (BFD)
Bidirectional Forwarding Detection (BFD) Bidirectional Forwarding Detection (BFD)
Bidirectional Forwarding Detection (BFD)
 
Network Mapper (NMAP)
Network Mapper (NMAP)Network Mapper (NMAP)
Network Mapper (NMAP)
 
Policy Based Routing (PBR)
Policy Based Routing (PBR)Policy Based Routing (PBR)
Policy Based Routing (PBR)
 
Routing Implementation - Cisco vs. Mikrotik
Routing Implementation - Cisco vs. MikrotikRouting Implementation - Cisco vs. Mikrotik
Routing Implementation - Cisco vs. Mikrotik
 
IT Service Level Agreement
IT Service Level AgreementIT Service Level Agreement
IT Service Level Agreement
 
SIP (Session Initiation Protocol)
SIP (Session Initiation Protocol)SIP (Session Initiation Protocol)
SIP (Session Initiation Protocol)
 
Denoising auto encoders(d a)
Denoising auto encoders(d a)Denoising auto encoders(d a)
Denoising auto encoders(d a)
 
Python Network Programming
Python Network ProgrammingPython Network Programming
Python Network Programming
 
Sns(social network service)
Sns(social network service)Sns(social network service)
Sns(social network service)
 
Machine learning in spam
Machine learning in spamMachine learning in spam
Machine learning in spam
 
DEVNET-1001 Coding 101: How to Call REST APIs from a REST Client and Python
DEVNET-1001 Coding 101: How to Call REST APIs from a REST Client and PythonDEVNET-1001 Coding 101: How to Call REST APIs from a REST Client and Python
DEVNET-1001 Coding 101: How to Call REST APIs from a REST Client and Python
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
 
JSON and REST
JSON and RESTJSON and REST
JSON and REST
 

Ähnlich wie Introduction to Python

Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Itzik Kotler
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1Abdul Haseeb
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE Saraswathi Murugan
 
Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data sciencedeepak teja
 
pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text ProcessingRodrigo Senra
 
Hands on Session on Python
Hands on Session on PythonHands on Session on Python
Hands on Session on PythonSumit Raj
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutesSumit Raj
 
Python_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txPython_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txvishwanathgoudapatil1
 
01-Python-Basics.ppt
01-Python-Basics.ppt01-Python-Basics.ppt
01-Python-Basics.pptVicVic56
 
Python Basics
Python BasicsPython Basics
Python BasicsPooja B S
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...DRVaibhavmeshram1
 
Chapter01_Python.ppt
Chapter01_Python.pptChapter01_Python.ppt
Chapter01_Python.pptPigPug1
 
Becoming a Pythonist
Becoming a PythonistBecoming a Pythonist
Becoming a PythonistRaji Engg
 
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲Mohammad Reza Kamalifard
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobikrmboya
 

Ähnlich wie Introduction to Python (20)

Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1
 
Pythonppt28 11-18
Pythonppt28 11-18Pythonppt28 11-18
Pythonppt28 11-18
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE
 
Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data science
 
pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processing
 
Hands on Session on Python
Hands on Session on PythonHands on Session on Python
Hands on Session on Python
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
 
Python_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txPython_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. tx
 
01-Python-Basics.ppt
01-Python-Basics.ppt01-Python-Basics.ppt
01-Python-Basics.ppt
 
Python basics
Python basicsPython basics
Python basics
 
python-2021.pdf
python-2021.pdfpython-2021.pdf
python-2021.pdf
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
 
Chapter01_Python.ppt
Chapter01_Python.pptChapter01_Python.ppt
Chapter01_Python.ppt
 
What is Python?
What is Python?What is Python?
What is Python?
 
Becoming a Pythonist
Becoming a PythonistBecoming a Pythonist
Becoming a Pythonist
 
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه اول پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobi
 
A Python Tutorial
A Python TutorialA Python Tutorial
A Python Tutorial
 

Mehr von KHNOG

Network Attack Counter
Network Attack CounterNetwork Attack Counter
Network Attack CounterKHNOG
 
Wireless Network Pentestration
Wireless Network PentestrationWireless Network Pentestration
Wireless Network PentestrationKHNOG
 
Core Concept of TCP/IP
Core Concept of TCP/IPCore Concept of TCP/IP
Core Concept of TCP/IPKHNOG
 
Bonding Interface in MikroTik
Bonding Interface in MikroTikBonding Interface in MikroTik
Bonding Interface in MikroTikKHNOG
 
Network Exploitation
Network ExploitationNetwork Exploitation
Network ExploitationKHNOG
 
Network Security-Honeypot
Network Security-HoneypotNetwork Security-Honeypot
Network Security-HoneypotKHNOG
 
Bandwidth Management on Linux
Bandwidth Management on LinuxBandwidth Management on Linux
Bandwidth Management on LinuxKHNOG
 
Why / How to become the Linux certified
Why / How to become the Linux certifiedWhy / How to become the Linux certified
Why / How to become the Linux certifiedKHNOG
 
Terminal Access Controller
Terminal Access ControllerTerminal Access Controller
Terminal Access ControllerKHNOG
 
Cambodia International Backbone Network
Cambodia International Backbone NetworkCambodia International Backbone Network
Cambodia International Backbone NetworkKHNOG
 
Introduction to BRAS
Introduction to BRASIntroduction to BRAS
Introduction to BRASKHNOG
 
ElasticISP
ElasticISPElasticISP
ElasticISPKHNOG
 
Hotspot on Mikrotik Router
Hotspot on Mikrotik RouterHotspot on Mikrotik Router
Hotspot on Mikrotik RouterKHNOG
 
Virtual Extensible LAN (VXLAN)
Virtual Extensible LAN (VXLAN)Virtual Extensible LAN (VXLAN)
Virtual Extensible LAN (VXLAN)KHNOG
 
Transmission Technologies
Transmission TechnologiesTransmission Technologies
Transmission TechnologiesKHNOG
 
Interior Routing Protocols
Interior Routing ProtocolsInterior Routing Protocols
Interior Routing ProtocolsKHNOG
 
Mikrotik Hotspot User Manager
Mikrotik Hotspot User ManagerMikrotik Hotspot User Manager
Mikrotik Hotspot User ManagerKHNOG
 
Testing Fiber-Optic Systems
Testing Fiber-Optic Systems Testing Fiber-Optic Systems
Testing Fiber-Optic Systems KHNOG
 
RPM Junos-service
RPM Junos-serviceRPM Junos-service
RPM Junos-serviceKHNOG
 
Incoming Outgoing Spam Filter
Incoming Outgoing Spam FilterIncoming Outgoing Spam Filter
Incoming Outgoing Spam FilterKHNOG
 

Mehr von KHNOG (20)

Network Attack Counter
Network Attack CounterNetwork Attack Counter
Network Attack Counter
 
Wireless Network Pentestration
Wireless Network PentestrationWireless Network Pentestration
Wireless Network Pentestration
 
Core Concept of TCP/IP
Core Concept of TCP/IPCore Concept of TCP/IP
Core Concept of TCP/IP
 
Bonding Interface in MikroTik
Bonding Interface in MikroTikBonding Interface in MikroTik
Bonding Interface in MikroTik
 
Network Exploitation
Network ExploitationNetwork Exploitation
Network Exploitation
 
Network Security-Honeypot
Network Security-HoneypotNetwork Security-Honeypot
Network Security-Honeypot
 
Bandwidth Management on Linux
Bandwidth Management on LinuxBandwidth Management on Linux
Bandwidth Management on Linux
 
Why / How to become the Linux certified
Why / How to become the Linux certifiedWhy / How to become the Linux certified
Why / How to become the Linux certified
 
Terminal Access Controller
Terminal Access ControllerTerminal Access Controller
Terminal Access Controller
 
Cambodia International Backbone Network
Cambodia International Backbone NetworkCambodia International Backbone Network
Cambodia International Backbone Network
 
Introduction to BRAS
Introduction to BRASIntroduction to BRAS
Introduction to BRAS
 
ElasticISP
ElasticISPElasticISP
ElasticISP
 
Hotspot on Mikrotik Router
Hotspot on Mikrotik RouterHotspot on Mikrotik Router
Hotspot on Mikrotik Router
 
Virtual Extensible LAN (VXLAN)
Virtual Extensible LAN (VXLAN)Virtual Extensible LAN (VXLAN)
Virtual Extensible LAN (VXLAN)
 
Transmission Technologies
Transmission TechnologiesTransmission Technologies
Transmission Technologies
 
Interior Routing Protocols
Interior Routing ProtocolsInterior Routing Protocols
Interior Routing Protocols
 
Mikrotik Hotspot User Manager
Mikrotik Hotspot User ManagerMikrotik Hotspot User Manager
Mikrotik Hotspot User Manager
 
Testing Fiber-Optic Systems
Testing Fiber-Optic Systems Testing Fiber-Optic Systems
Testing Fiber-Optic Systems
 
RPM Junos-service
RPM Junos-serviceRPM Junos-service
RPM Junos-service
 
Incoming Outgoing Spam Filter
Incoming Outgoing Spam FilterIncoming Outgoing Spam Filter
Incoming Outgoing Spam Filter
 

Kürzlich hochgeladen

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Kürzlich hochgeladen (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Introduction to Python

  • 1. Introduction to Python for Network Engineer (Basic)
  • 2. Before We Start Do you know these following languages? ´  C/C++ ´  Java ´  Shell ´  Batch ´  TCL ´  Python
  • 3. Python Overview ´  A script programming language ´  A high-level programming language  ´  object-oriented ´  No compilation ´  No datatype declaration
  • 4. What can Python do? Many many things which Python could do but the only one thing we will talk about is “ Network Automation”
  • 5. Running Python: Interactively Python is pre-installed on Linux platform [porhai@python ~]$ python Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> print "Hello world" Hello world >>>
  • 6. Running Python: .py file [porhai@python ~]$ vi khnog.py print "hello world" ~ ~ [porhai@python ~]$ python khnog.py hello world [porhai@python ~]$
  • 7. Python VS Shell [porhai@python ~]$ echo Hello World Hello World [porhai@python ~]$ >>> print "Hello world" Hello world >>> Shell Python
  • 8. Python VS Shell [porhai@python ~]$ vi khnog.sh echo Hello World ~ [porhai@python ~]$ sh khnog.sh Hello World [porhai@python ~]$ Shell Python [porhai@python ~]$ vi khnog.py print "hello world" ~ [porhai@python ~]$ python khnog.py hello world [porhai@python ~]$
  • 9. Python Input/Output >>> x = raw_input("x = ") x = 123 >>> >>> print x 123
  • 10. Python Datatypes ´  Integer (int) ´  Float (float) ´  String (str) ´  List (list) ´  Dictionary (dict) >>> x=1 >>> type(x) <type 'int'> >>> x="hello" >>> type(x) <type 'str'> >>> >>> x=[1,2,3] >>> type(x) <type 'list'> >>> x={'name':'porhai', 'age':22} >>> type(x) <type 'dict'> >>> x=1.1 >>> type(x) <type 'float'>
  • 11. Python Modules ´  Telnetlib ´  Paramiko ´  Smtplib ´  PySNMP
  • 12. Python Program Example ´  Login to Switch ´  Enter Username and Password ´  Get configuration of interface ´  Output result
  • 13. Python Code [porhai@python ~]$ vi khnog.py import telnetlib def open_telnet_conn(ip): #Change exception message try: #Define telnet parameters username = 'porhai' password = 'porhai' TELNET_PORT = 23 #Logging into device connection = telnetlib.Telnet(ip, TELNET_PORT, TELNET_TIMEOUT)
  • 14. Python Code connection.write(username + "n") connection.write(password + "n") time.sleep(1) connection.write("show run int g0/1 n") time.sleep(1) Output = connection.read_very_eager() print Output #Closing the connection connection.close() except IOError: print "Input parameter error! Please check username, password and file name." open_telnet_conn("10.1.1.1")
  • 15. Python Program Executed [porhai@python ~]$ python khnog.py User Access Verification Username: porhai Password: S1#show run int g0/1 Building configuration... Current configuration : 66 bytes ! interface GigabitEthernet0/1 no switchport no ip address end
  • 16. Reference ´  Python Language Comparison https://www.python.org/doc/essays/comparisons/ Shell ´  Python Lesson http://learnpythonthehardway.org/ ´  Python for Network Engineers https://pynet.twb-tech.com/