-
【Python有坑系列】python中编码问题——unicode, gbk, utf8
所属栏目:[Python] 日期:2020-12-17 热度:65
p style="margin-left:10px;" 1.默认编码类型 p style="margin-left:10px;"? pre class="has" code class="language-python" import sys sys.getdefaultencoding() 'utf-8' python 3.4默认为utf-8编码,python 3.4默认为Ascii编码 2. Python3 中字符串的类型[详细]
-
python调用新浪API爬虫
所属栏目:[Python] 日期:2020-12-17 热度:61
2. 下载pytho SDK 。,默认支持python2.6/2.7. 改为python3.4版本。 3. 报错:"访问出错了.你所访问的站点在新浪微博的认证失败,请联系****或者稍后再试.(error:redirect_uri_mismatch) 新浪微博版权所有." 4.?[详细]
-
python爬虫入门
所属栏目:[Python] 日期:2020-12-17 热度:150
1. 从下载项目源码,请支持作者本人。 2. 安装提到的各种库。 顺便学习一下beautiful soup的用途: 3.?? 安装MYSQL,net start mysql ??启动报错: 报错1,系统找不到指定的文件。 解决方案:根据错误日志,修改注册表。 修改注册表有三种方式:。我选择用wi[详细]
-
python——time模块用法
所属栏目:[Python] 日期:2020-12-17 热度:149
time模块下有两种时间表示方法: 第一种是:时间戳的方式。 是基于1970年1月1日0时0分0秒的偏移。浮点数。 第二种是:struct_time()类型的表示方法。 gmtime()和localtime()可以将时间戳显示为struct_time()类型。 第三种是:格式化时间。 格式化显示。 strp[详细]
-
饿了么黑客马拉松——环境配置
所属栏目:[Python] 日期:2020-12-17 热度:192
1.?: VirtualBox是一个虚拟化软件,用来在我们的电脑上虚拟出一电脑来。 Vagrant 就是一个命令行版的虚拟机管理程序,通过集成命令操作 VirtualBox / VMware 等虚拟机程序来操作操作系统。 如果项目有多个开发人员, 保障大家的开发环境都一样。环境只配置[详细]
-
python中urllib模块
所属栏目:[Python] 日期:2020-12-17 热度:120
打开一个url的方法,返回一个文件对象,然后可以进行类似文件对象的操作。本例试着打开google >> import urllib>>> f = urllib.urlopen('http://www.google.com.hk/')>>> firstLine = f.readline() #读取html页面的第一行>>> firstLine' Google (function(){[详细]
-
python编码知识点(倒序更新)
所属栏目:[Python] 日期:2020-12-17 热度:167
在python中进行编码转换都是通过unicode作为中间值实现的。 decode的作用是将其他编码的字符串转换成unicode编码,如str1.decode(gb2312),表示将gb2312编码的字符串转换成unicode编码。 encode的作用是将unicode编码转换成其他编码的字符串,如str2.encode([详细]
-
Python正则表达式
所属栏目:[Python] 日期:2020-12-17 热度:107
贪婪模式和非贪婪模式。 主要是*和?的区别。前者匹配尽可能多,后者匹配尽可能少 >> import re>>> a = "abbbb">>> pattern = re.compile('ab*')>>> match = pattern.match(a)>>> print match.group()abbbb>>> pattern = re.compile('ab?')>>> match = patter[详细]
-
【Python】python中plot用法——线条、点、颜色
所属栏目:[Python] 日期:2020-12-17 热度:181
图的存在,让数据变得形象化。无论多么复杂的东西,都是简单的组合。 plot画图时可以设定线条参数。包括:颜色、线型、标记风格。 1)控制颜色 颜色之间的对应关系为 b---blue ? c---cyan ?g---green ? ?k----black m---magenta r---red ?w---white ? ?y----[详细]
-
python题目:一个小小的猜名有戏
所属栏目:[Python] 日期:2020-12-17 热度:194
def drawMan(errCount): if errCount == 1: print "head" if errCount == 2: print "body" if errCount == 3: print "left hand" if errCount == 4: print "right hand" if errCount == 5: print "left foot" if errCount == 6: print "right foot" if name[详细]
-
matplotlib画图
所属栏目:[Python] 日期:2020-12-17 热度:180
参考文档: 1. 图中加标注 2. 柱状图 p style="text-align:center;" ? ? ? ?? 3.?colormap图 p style="text-align:center;" '+fn) #fn='/d3/MWRT/R20130805/F06925_EMS60.txt' data=wlab.dlmread(fn) EMS=EMS+list(data[:,1])#地表发射率 LST=LST+list(data[[详细]
-
#《Hadoop权威指南》——Hadoop简介
所属栏目:[Python] 日期:2020-12-17 热度:133
p style="text-align:left;" p style="font-size:13.3333339691162px;"span style="font-family:'Microsoft YaHei';" h3 style="font-family:Verdana,Arial,Tahoma;line-height:25px;" span style="font-family:'Microsoft YaHei';"span style="color:#ff000[详细]
-
Coursea Hadoop课堂笔记——Lesson 1: Big Data Hadoop Stack
所属栏目:[Python] 日期:2020-12-17 热度:114
p style="font-size:13.3333339691162px;"span style="color:rgb(153,0);font-size:13.3333339691162px;" 课后习题 p style="font-size:13.3333339691162px;"span style="font-size:13.3333339691162px;"span style="color:rgb(51,51,51);"课堂中: Hadoop m[详细]
-
Hadoop单机学习环境配置
所属栏目:[Python] 日期:2020-12-17 热度:179
: 以下是简单命令摘要: 安装虚拟机VM ——> 安装centos ——> 1. 生成组用户 sudo groupadd hadoop sudo useradd –s /bin/bash –d /home/ztf –m ztf –g hadoop –G admin sudo passwd zhm su zhm? /etc/sudoers: ## Allow root to run any commands a[详细]
-
【Python】Python-numpy逻辑报错:The truth value of an array
所属栏目:[Python] 日期:2020-12-17 热度:91
报错代码: pre class="has" code class="language-python"import numpy as np a=np.zeros(3) a[0]=0; a[1]=1; a[2]=2 if a==[1,2,3]: print "OK" else: print "NOT OK" Traceback (most recent call last): File "pyshell#45",line 1,in if a==[1,3]: Value[详细]
-
python—networkx:各个布局的源代码
所属栏目:[Python] 日期:2020-12-17 热度:168
Source code for networkx.drawing.layout 方便学习与重新封装 Node positioning algorithms for graph drawing. """ Copyright (C) 2004-2015 by Aric Hagberg hagberg@lanl.gov Dan Schult dschult@colgate.edu Pieter Swart swart@lanl.gov All rights re[详细]
-
python解析:Java环境配置简化版
所属栏目:[Python] 日期:2020-12-17 热度:157
运行->键入cmd->在窗口中输入 javac-> 回车,看看是否出来java相关命令的参数。 4. 安装eclipse[详细]
-
Python:字符串的多重替换
所属栏目:[Python] 日期:2020-12-17 热度:106
字符串的多重替换: (1)把str中出现的所有s1字符串替换为str2字符串:str.replace(s1,s2)? (2)把str中出现的所有s1,s2字符串分别替换为s3,s4字符串:str.replace(s1,s3) .replace(s2,s4) (3)把str中出现的所有s1,s2字符串替换为s3字符串:酌情使用[详细]
-
Python:如何将字符串作为变量名
所属栏目:[Python] 日期:2020-12-17 热度:102
>> var = "This is a string">>> varName = 'var'>>> s= locals()[varName]>>> s'This is a string'>>> s2=vars()[varName]>>> s2'This is a string'>>> s3=eval(varName)>>> s3'This is a string' 。[详细]
-
Python工具:保留小数的指定有效位数
所属栏目:[Python] 日期:2020-12-17 热度:124
处理一个数据文件,发现数据不一致,小数点后有三位、四位、六位、更多位。部分还进行四舍五入。 需要对数据文件进行处理。如果有效位超过6位,则四舍五入。如果小于6位,则保持原来的数字不变。 考虑两种情况: 小数点后无数字:判断数字有效位(len(str(nu[详细]
-
python:inspect函数自动生成函数名
所属栏目:[Python] 日期:2020-12-17 热度:124
有时候我们会碰到这样的需求,需要执行对象的某个方法,或是需要对对象的某个字段赋值,而方法名或是字段名在编码代码时并不能确定,需要通过参数传递字符串的形式输入。举个具体的例子:当我们需要实现一个通用的DBM框架时,可能需要对数据对象的字段赋值,[详细]
-
python:if __name__ == '__main__': 的作用
所属栏目:[Python] 日期:2020-12-17 热度:130
h1 class="postTitle"span style="font-size:12px;font-weight:normal;" h1 class="postTitle"span style="font-size:12px;font-weight:normal;"当你打开一个.py文件时,经常会在代码的最下面看到if name == ' main ':,现在就来介 绍一下它的作用. h1 class="[详细]
-
python:有序字典与嵌套字典
所属栏目:[Python] 日期:2020-12-17 热度:172
>> import collections>>> d=dict()>>> d['a']='A'>>> d['b']='B'>>> d['c']='C'>>> for k,v in d.items(): print k,va Ac Cb B >> import collections>>> d=collections.OrderedDict()>>> d['a']='A'>>> d['b']='B'>>> d['c']='C'>>> dOrderedDict([('a','A[详细]
-
python:pandas包
所属栏目:[Python] 日期:2020-12-17 热度:188
请教前辈一个例子:列表如何按列取数。然后学到了一个大招——pandas,记录在此: 后来琢磨了一下,其实python本身语法也可以轻松解决。 例如,通过迭代器取arr数组第1列数:[详细]
-
Jython:java调用python文件之第三方包路径问题
所属栏目:[Python] 日期:2020-12-17 热度:130
本方法解决python代码的可移植性,不需要在新机器上配置python环境,只通过安装jython的方式将python代码嵌入java工程 1. Jython如何安装 下载地址:。下载需要积分,如果无积分,可联系楼主。 傻瓜式下一步安装方式,路径最好和工程选在同一目录下。 2. 运[详细]
