python使用socket连接远程服务器的方法
作者:重负在身 时间:2022-12-12 23:55:16
本文实例讲述了python使用socket连接远程服务器的方法。分享给大家供大家参考。具体如下:
import socket
print "Creating socket...",
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
print "done."
print "Looking up port number...",
port = socket.getservbyname('http', 'tcp')
print "done."
print "Connecting to remote host on port %d..." % port,
s.connect(("www.jb51.net", port))
print "done."
希望本文所述对大家的Python程序设计有所帮助。
标签:python,socket
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
js实现div闪烁原理及实现代码
2024-04-16 09:05:02
python 动态调用函数实例解析
2021-03-11 09:31:41
详解pytorch的多GPU训练的两种方式
2023-08-04 09:58:29
![](https://img.aspxhome.com/file/2023/7/70827_0s.jpg)
详解scrapy内置中间件的顺序
2023-10-22 07:13:38
面试被问select......for update会锁表还是锁行
2024-01-17 20:59:17
![](https://img.aspxhome.com/file/2023/9/121579_0s.png)
Jupyter notebook如何修改平台字体
2022-03-21 13:37:59
![](https://img.aspxhome.com/file/2023/5/131015_0s.png)
python项目报错:bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requests
2022-07-17 05:39:02
![](https://img.aspxhome.com/file/2023/4/92114_0s.jpg)
vue中如何实现变量和字符串拼接
2024-04-30 10:21:22
![](https://img.aspxhome.com/file/2023/1/130261_0s.png)
Selenium定位浏览器弹窗方法实例总结
2022-07-03 05:17:24
![](https://img.aspxhome.com/file/2023/0/127610_0s.png)
Python爬虫实现搭建代理ip池
2022-05-19 06:57:11
![](https://img.aspxhome.com/file/2023/8/105618_0s.png)
spring mvc4.1.6 spring4.1.6 hibernate4.3.11 mysql5.5.25开发环境搭建图文教程
2024-01-23 12:27:19
![](https://img.aspxhome.com/file/2023/4/68734_0s.jpg)
跟我学习javascript的异步脚本加载
2024-04-17 09:59:44
python字符串拼接+和join的区别详解
2021-10-19 01:26:39
![](https://img.aspxhome.com/file/2023/6/135206_0s.png)
python用pickle模块实现“增删改查”的简易功能
2022-01-13 06:38:56
Go项目编写Makefile规则文件概述
2024-02-06 01:20:07
利用golang的字符串解决leetcode翻转字符串里的单词
2023-07-17 16:36:21
![](https://img.aspxhome.com/file/2023/8/99048_0s.jpg)
基于insertBefore制作简单的循环插空效果
2023-08-17 22:34:17
![](https://img.aspxhome.com/file/2023/2/55932_0s.png)
6G数据库的导入 报各种错误的解决办法
2024-01-28 09:58:22
![](https://img.aspxhome.com/file/2023/8/121598_0s.jpg)
基于Python实现的恋爱对话小程序详解
2023-01-14 11:08:38
![](https://img.aspxhome.com/file/2023/8/134798_0s.png)
SQL2005学习笔记 EXCEPT和INTERSECT运算符
2024-01-14 16:15:15