We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f924371 commit 0278826Copy full SHA for 0278826
libs/python.wiki
@@ -749,6 +749,38 @@ Home:[https://bitbucket.org/jaraco/irc]
749
750
IRC 是 Internet Relay Chat 的缩写。这是用 Python 封装的第三方库。
751
752
+=== 5.3.6 远程控制 ===
753
+
754
+<h4>telnetlib</h4>
755
756
+【标准库】
757
758
+封装 telnet 协议
759
760
+代码示例——使用 telnet 登录到某个主机并执行简单命令
761
+<source lang="python">
762
+import telnetlib
763
+import getpass
764
765
+host = raw_input("Enter remote host: ")
766
+user = raw_input("Enter your remote account: ")
767
+password = getpass.getpass()
768
769
+tn = telnetlib.Telnet(host)
770
771
+tn.read_until("login: ")
772
+tn.write(user + "\n")
773
774
+if password :
775
+ tn.read_until("Password: ")
776
+ tn.write(password + "\n")
777
778
+tn.write("ls\n")
779
+tn.write("exit\n")
780
781
+print tn.read_all()
782
+</source>
783
784
== 5.4 自定义的应用层 ==
785
786
<h4>Protocol Buffers</h4>
0 commit comments