import getpassimport telnetlibHOST = "192.168.122.72"user = input("Enter your telnet username: ")password = getpass.getpass()tn = telnetlib.Telnet(HOST)tn.read_until(b"Username: ")tn.write(user.encode('ascii') + b"\n")if password: tn.read_until(b"Password: ") tn.write(password.encode('ascii') + b"\n")tn.write(b"enable\n")tn.write(b"cisco\n")tn.write(b"conf t\n")for n in range (2,101): tn.write(b"vlan " + str(n).encode('ascii') + b"\n") tn.write(b"name Python_VLAN_" + str(n).encode('ascii') + b"\n")tn.write(b"end\n")tn.write(b"wr\n")tn.write(b"exit\n")print(tn.read_all().decode('ascii'))Burada tn.write'dan hemen sonra parantez içinde başlayan 'b'ler neyi ifade ediyor ,esenlikler.
Stack OverflowWhat does the 'b' character do in front of a string literal?https://stackoverflow.com/questions/6269765/what-does-the-b-character-do-in-front-of-a-string-literal