Python基础学习-'module' object has no attribute 'urlopen'解决方法
import numpy as np
import urllib url = "http://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data"
# 下载网络数据
raw_data = urllib.urlopen(url)
# 处理网络下载的数据为矩阵,方便后面的数据操作
dataset = np.loadtxt(raw_data, delimiter=",")
# 提取特征矩阵数据,dataset中的所有行,所有0-7列的数据都保存在X中
X = dataset[:,0:7]
# 提取目标变量数据,dataset中的所有行,所有8列的数据都保存在y中
y = dataset[:,8]
运行程序会报错module 'urllib' has no attribute 'urlopen'
import numpy as np
import urllib.request url = "http://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data"
# 下载网络数据
raw_data = urllib.request.urlopen(url)
# 处理网络下载的数据为矩阵,方便后面的数据操作
dataset = np.loadtxt(raw_data, delimiter=",")
# 提取特征矩阵数据,dataset中的所有行,所有0-7列的数据都保存在X中
X = dataset[:,0:7]
# 提取目标变量数据,dataset中的所有行,所有8列的数据都保存在y中
y = dataset[:,8]
Python基础学习-'module' object has no attribute 'urlopen'解决方法的更多相关文章
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...
- 'module' object has no attribute 'Thread'解决方法及模块加载顺序
源码片段: class myThread(threading.Thread): def __init__(self, threadID, name, counter): threading.Threa ...
- 提示AttributeError: 'module' object has no attribute 'HTTPSHandler'解决方法
今天在新机器上安装sqlmap,运行提示AttributeError: 'module' object has no attribute 'HTTPSHandler' 网上找了找资料,发现一篇文章ht ...
- python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?
python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...
- pygame模块使用时出现AttributeError: module ‘pygame’ has no attribute '…'错误解决方法
pygame模块使用时出现AttributeError: module 'pygame' has no attribute '-'错误解决方法 首先在pygame中存在init()模块,出现这样的问题 ...
- 【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法
pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法 解决方法: 在pycharm的安装目 ...
- [开发技巧]·AttributeError: module 'pywt' has no attribute 'wavedec'解决方法
[开发技巧]·AttributeError: module 'pywt' has no attribute 'wavedec'解决方法 1.卸载 pywt pip uninstall pywt 2.安 ...
- AttributeError: module '__main__' has no attribute 'main'解决方法
在终端运行.py文件时报错:AttributeError: module '__main__' has no attribute 'main' 原因:在PyCharm里运行python程序需要添加 i ...
- python 错误AttributeError: 'module' object has no attribute 'AF_INET'
写了一个简单的python socket的程序.运行时,报错如下 原因:文件的命名与Python的function的命名冲突 修改名称后,发现还是无法运行,检查目录下面是否有 这样子的一个文件,删除即 ...
随机推荐
- Linux入门(8)——Ubuntu16.04安装sublime text 3并配置Python开发环境
打开终端,添加sublime text 3的仓库: 按enter键继续 更新软件库: sudo apt-get update 安装Sublime Text 3: sudo apt-get instal ...
- Appium python自动化测试系列之滑动函数封装实战(八)
8.1 什么是函数的封装 教科书上函数的封装太官方,我们这里暂且将函数的封装就是为了偷懒把一些有共性的功能或者一些经常用的功能以及模块放在一起,方便我们以后再其他地方调用.这个只是个人的理解所以大家懂 ...
- Java基础总结--多线程总结1
----进程和线程-----1.概述:简单理解一个进程就是一个正在运行的程序(程序在内存中的所属空间)程序只有在运行的时候才会被加载进内存2.进程内部的划分进程不会直接执行,只是被当作分配内存资源的基 ...
- mysql 外键的几种约束
restrict方式 同no action, 都是立即检查外键约束 --限制,指的是如果字表引用父表的某个字段的值,那么不允许直接删除父表的该值: cascade方式 在父表上update/de ...
- css中居中方法小结
---恢复内容开始--- 1.文字垂直居中 .header_nav-item{ height:38px; line-height:38px; } 即文字所在模块的高度和行高设置成一样的! 2.块元素垂 ...
- Nodejs MSSQL详细解读
MSSQL 是Nodejs用于连接Microsoft SQL Server 的插件. 安装方法 npm install mssql 配置Config const config = { user: '. ...
- MQTT——连接报文
学习MQTT协议.如果只是看了相关文档就认为可以了.那是一个错误的观念.笔者为了能更好的去理解MQTT协议.看了不少相关的开源Broker的项目.可惜这些项目一般都是不完全的.不过从这些项目中笔者至少 ...
- spring boot 自己输出json数据
@RequestMapping("/json")public void json(HttpServletResponse response, Pager pager, TruckF ...
- C++11 static_assert
C++11 static_assert C++0x中引入了static_assert这个关键字,用来做编译期间的断言,因此叫做静态断言. 其语法:static_assert(常量表达式,提示字符串). ...
- HDU 3584 Cube(三位树状数组)
Cube Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submi ...