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 笔记-cp命令
常用参数: -a :将文件的特性一起复制 -p :连同文件的属性一起复制,而非使用默认方式,与-a相似,常用于备份 -i :若目标文件已经存在时,在覆盖时会先询问操作的进行 -r :递归持续复制,用于 ...
- LeetCode 661. Image Smoother (图像平滑器)
Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother t ...
- CRUSH: Controlled, Scalable, Decentralized Placement of Replicated Data译文
原文地址:http://www.oschina.net/translate/crush-controlled-scalable-decentralized-placement-of-replicate ...
- 如何用java创建一个jdbc程序
第一个jdbc程序 JDBC简介 Java数据库连接(Java Database Connectivity,JDBC),是一种用于执行SQL语句的Java API,它由一组用Java编程语言编写的类和 ...
- 2-SAT问题总结
2-SAT问题总结 2-SAT问题:n个布尔型的变量,给出m个约束条件,约束条件例如:A,B不能同时为真,A,B必须同时为真等. 看了算法入门经典中的解决办法,关于这种解决办法比较容易理解,并且效率也 ...
- 实现基于lnmp的电子商务网站
今天带给大家的是一个实战项目,主要是让大家了解在我们接到一个项目时,我们该怎样做好这个项目,下面看具体内容: 技术说明 LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器 ...
- transform的影响
http://www.cnblogs.com/chuangweili/p/5167986.html transform 各种影响 1.提升元素的z-index层级,下面这个例子会让前面的图片显示在上面 ...
- 阿里云RDS for SQL Server使用的一些最佳实践
了解RDS的概念 这也是第一条,也是最重要的一条,在使用某项产品和服务之前,首先要了解该产品或服务的功能与限制,就像你买一个冰箱或洗衣机,通常也只有在阅读完说明书之后才能利用起来它们的所以功能,以及使 ...
- CentOS卸载原有旧版OPENJDK并安装SUNJDK解决方案
PS:由于图片是安装后进行截图所以出现的是1.8版本,步骤是完全正确的. 一.检测JDK 首先你要打开终端,为避免可能出现的权限问题建议直接su进入root.(PS:密码可以输入但不显示) 然后输入j ...
- ajax事件请求
首先,ajax是什么? ajax是一种在无需重新加载整个网页的情况下,能够更新部分网页的技术. ajax是一种用于创建的快速动态网页的技术. 当async:true时,表示异步执行ajax代码:当as ...