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的命名冲突 修改名称后,发现还是无法运行,检查目录下面是否有 这样子的一个文件,删除即 ...
随机推荐
- JavaScript中的比较规则之“==”运算符
"=="运算符(两个操作数的类型不相同时) 如果一个值是null,另一个值是undefined,则它们相等 如果一个值是数字,另一个值是字符串,先将字符串转换为数学,然后使用转换后 ...
- 超文本传送协议HTTP
1. HTTP的操作过程: HTTP是面向事务的应用层协议.HTTP协议本身是无连接的,为了保证数据的可靠传输,HTTP使用了面向连接的TCP作为运输层协议.所以,在发送HTTP报文之前都需要先建立T ...
- 聊聊 Material Design 里,阴影的那些事儿!
当你的设计师要求你在某个 View 上增加阴影效果,那你只需要认真阅读本文,阴影的问题就不再是问题. 一.前言 设计师的世界,与常人不同,有时候想要扁平化的风格,有时候又想要拟物化的风格.而在 Mat ...
- 微信小程序之bindtap事件绑定传参
wxml代码: <view class='fen'> <text bindtap='prev' data-page="{{pageDang}}">上一页&l ...
- Ionic3 一些命令
ionic start --help E:\Projects\ionic>ionic start --help ionic start - Create a new project This c ...
- 手工搭建ABP框架(1) - Web项目
为了防止不提供原网址的转载,特在这里加上原文链接: http://www.cnblogs.com/skabyy/p/7295533.html ABP是 ASP.NET Boilerplate Proj ...
- Even Tree 小议
原题链接:https://www.hackerrank.com/challenges/even-tree/problem 思路:把树还原出来,对每个结点,计算以该结点为根的子树结点数.子树结点数为偶数 ...
- AngularJS学习篇(七)
AngularJS 过滤器 过滤器可以使用一个管道字符(|)添加到表达式和指令中. <!DOCTYPE html> <html> <head> <meta c ...
- sql 1.1 1.1.1 1.10.1 排序
解决思路:计算每位的权重,得到序号完整的权重值,使用权重值进行排序! 创建sql 函数如下: ALTER FUNCTION [dbo].[SequenceToOrderNum] ( @Sequence ...
- Python 3.X 调用多线程C模块,并在C模块中回调python函数的示例
由于最近在做一个C++面向Python的API封装项目,因此需要用到C扩展Python的相关知识.在此进行简要的总结. 此篇示例分为三部分.第一部分展示了如何用C在Windows中进行多线程编程:第二 ...