Professional Documents
Culture Documents
Python Basic 2024
Python Basic 2024
PYTHON
AGENDA
- Introduction
- Install Visual studio code/ python
- Variable
- Comparison Operators
- if else
- loop
- List, Dictionary
- Read Write File
- Library paramiko
- Code Backup Fortigate
- Code Config Fortigate
2
SETUP(1)
SETUP(1)
SETUP(2)
SETUP(3)
Setting VS Code
Variable
• เป็ นการสร้างตัวแปรเพื่อมาเก็บค่าบางอย่าง โดยจะใช้ชื่อให้สื่อความกับสิ่ งเราต้องการจะเก็บ เช่น
แต่ขอ้ ห้ามในการตั้งคือ ไม่ควรจะตั้งชื่อซ้ ากับ Function ใน Python เช่น str,int,max,sum เป็ นต้น
String
Syntax :
a =“hello”
a= ‘hello’
Int,Float
Syntax :
a=1
a=-10
Syntax :
a = 1.2
a=-10.22
Comparison Operators
Python if else
Syntax :
if(statement):
print(“True”)
else:
print(“false”)
For Loops
•syntax
•List1 =[1,2,3,4,5,6,7]
•for num in List1 :
•print(num)
While loops
•Syntax :
• count = 0
• while count < 5:
• print(count)
• count +=1
Lists
•Syntax:
• List =[value1,value2,value3,….valueN]
Dictionary
Syntax :
dic
={key1:value1,key2:value2,….keyN:valueN}
Files I/O
Files I/O
• Syntax :
• File = open(filename,’r’)
• Read_file=File.read()
• File.close()
• Print(Read_file)
• ###############################
• File = open(filename,’w’)
• File = write(“hi SNK”)
• File.close()
การเชื่ อมต่ ออุปกรณ์ Network