域名到IP 报错socket.gaierror: [Errno 8] nodename nor servname provided, or not known
Python中如何通过域名,查看对应的IP?
请看如下代码:
import socket
hostname="www.baidu.com"
ip = socket.gethostbyname(hostname)
print "ip:", ip
看下执行结果:
ip: 112.80.248.75
如果配置的hostname有问题,或者说域名配置错误,就会出现如下报错:
Traceback (most recent call last):
File "t.py", line 5, in <module>
ip = socket.gethostbyname(hostname)
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
域名到IP 报错socket.gaierror: [Errno 8] nodename nor servname provided, or not known的更多相关文章
- 一站式解决Mac--socket.gaierror: [Errno 8] nodename nor servname provided, or not known
socket.gaierror: [Errno 8] nodename nor servname provided, or not known 原因:hostname 没有写在/etc/hosts里 ...
- cloudera安装报错 socket.gaierror: [Errno -2] Name or service not known
有时候安装cloudera会报socket.gaierror: [Errno -2] Name or service not known,或者服务器可能IP或mac地址冲突会引发次错误.导致机器服务不 ...
- 训练DQN,报错:OSError: [Errno 12] Cannot allocate memory
训练DQN,报错:OSError: [Errno 12] Cannot allocate memory 问题介绍: 这两天在做强化学习的作业,使用 DQN 打 Atari 游戏,但在训练过程中,出现了 ...
- 【Selenium】【BugList9】windows环境,fp = open("./"+ time.strftime("%Y-%m-%d %H:%M:%S") + " result.html",'wb'),报错:OSError: [Errno 22] Invalid argument: './2018-09-05 10:29:32 result.html'
[代码] if __name__=="__main__": suite = unittest.TestSuite() suite.addTest(Baidu("test_ ...
- Let's encrypt申请泛域名证书以及报错处理
申请泛域名证书的步骤请参考该链接地址: https://www.jianshu.com/p/df6d13187578 报错信息: No matching distribution found for ...
- vamare下centos7.0 动态获取ip报错问题
CentOS7 Failed to start LSB: Bring up/down解决方法 centos7.0中service network restart重启报错的问题 报错信息: /etc/i ...
- Python创建文件报错OSError:[Errno 22] Invalid argument处理
问题: windows平台下使用python open函数w模式打开文件报错“OSError: [Errno 22] Invalid argument: '../news/“消费升维”成零售业新风口? ...
- @vue/cli 3 运行支持报错 socket
问题 /sockjs-node/info 无限报错 解决方案 原因是相关代理端不支持 ws,因此需要在代理处关闭 ws,即 ws: false,如下: vue.config.js const ds_p ...
- GreenPlum 初始化配置报错:gpadmin-[ERROR]:-[Errno 12] Cannot allocate memory
报错原因:可能swap太小或者没有交换分区 解决方法: (1)查看swap:swapon -s (2)如果什么都没有显示,说明你没有任何可用的swap,此时你可以添加1GB的swap: dd if=/ ...
随机推荐
- Redis的keyspace notification(键空间通知)
文章来源https://www.cnblogs.com/tinywan/p/5903988.html 一.需求分析: 设置了生存时间的Key,在过期时能不能有所提示? 如果能对过期Key有个监听,如何 ...
- Windows Server 2016分层式存储,使用PowerShell修改底层介质类型
新部署的备份服务器,需要做分层式存储,按照网上最常见一个作者叫刘兵的文档,名叫<Windows Server2016分层存储技术详细拆解手册>,做到使用PowerShell修改磁盘的Med ...
- three.js之创建一个几何体
<html> <head> <title>My first three.js app</title> <style> body { marg ...
- 7.控制计划任务crontab命令
at 命令是针对仅运行一次的任务,循环运行的例行性计划任务,linux系统则是由 cron (crond) 这个系统服务来控制的Linux 系统上面原本就有非常多的计划 性工作,因此这个系统服务是默认 ...
- 修改虚拟机CentOS系统ip地址和主机名
按照教程安装了虚拟机但是未配置静态IP,所以导致IP地址经常变化,CRT,mysql等连接时经常出现问题. 所以修改虚拟机内CentOS系统的IP为静态IP. 一.查看当前网关 虚拟机-->[编 ...
- java线程基础巩固---通过实验分析This锁和Class锁的存在
This锁: 关于什么是This锁下面用实现来说明一下它: 那下面用两个线程分别调用这两个方法,如下: 看结果: 可见两个方法是同时输出的,因为m2()方法并未上锁,所以就不存在争锁的问题,那这时给m ...
- golang 系列学习(-) 数据类型
数据类型的出现 在的编程语言中,数据类型用于声明函数和变量,数据类型的出现是为了要把数据分成数据所需要内存大小的不同数据,编程时需要什么样的内存就申请什么样的内存.就可以充分的利用内存,更好的霸控程序 ...
- Java-收邮件
import java.util.Properties; import javax.mail.Folder; import javax.mail.Message; import javax.mail. ...
- Web前端开发——HTML基本标签
标题h1-h6 只有h1到h6,没有h7. 一个页面建议只有一个h1 普通文字大小大约介于h3~h4 段落p 段内换行br 段内分组span 预留格式pre 水平线hr
- Linux - TCP/IP网络协议基础
1.0 Tcp / IP 背景介绍 上世纪70年代,随着计算机的发展,人们意识到如果想要发挥计算机的更大作用,就要讲世界各地的计算机连接起来. 但是简单的连接时不够的,因为计算机之间无法沟通.因此设计 ...