In this video, we are going to learn about decode. Here in the line 21, we have decode script. 2
I said before, that the data type of output is byte, and if we print the byte, 3
the output is not good, this is why we use decode here. 4
So this decode is used to convert 5
from byte to string. Let’s try to remove this decode and see what happened. 6
Let’s change the loopback to loopback3, and the ip address is 10.1.1.4. save, 7
Let’s run the script, clear, and then python paramiko_basic.py, 8
Just enter here, the username also just enter, and the password, also just enter. 9
Here we can see that we are success login to router 1, and we also success to send 10
the configuration, but here we can see b, this is means byte. And the output is not good like this. 11
But the command is sent to the router 1. Let’s check it. 12
Show ip interface brief exclude unassign. 13
Here we can see that we have loopback3, 14
and the ip address is 10.1.1.4, this is the loopback interface that we just create. 15
Okay, so once again, the data type of output is byte, we also can print the data type, 16
here let’s print type and then output. 17
Save, 18
Let’s run the script again, python3 paramiko_basic.py, just enter enter here. 19
Here we can see that the data type is byte. 20
Now let’s put the decode again. Remember that decode is used to convert byte to string. 21
Save, back to terminal, and run the script again, just enter enter here. 22
Here we can see that now the data type is string. 23
And now the output is good. 24
Okay I hope you understand the function of decode. 25
I think enough for this video 26
Thank you for watching and see you on the next video.