- 浏览: 11441 次
- 性别:
- 来自: 北京
最新评论
文章列表
#!/usr/bin/perl
use 5.010;
#词法与动态作用域
$a = 20; #全局变量
{
local ($a); #临时变量,保存全局变量,新值为undef
$a = 10;
#say $a;
}
#say $a;
#Typeglob创建标识符别名
#local临时别名
$b = 30;
{
#local (*b);
local *b; #创建临时别名(保存全局*b的值,然后将新值赋为undef)
*b = *c; #创建变量c的别名b
$b += 10;
}
...
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
#say "Hello, World...\n";
for (my $i=1;$i<10 ;${i}++) {
#print "count $i!\n";
}
use File::Basename;
#use File::Basename (); #不引入函数
#use File::Basename qw / /;#不引入函数
#use File::Basename qw /basename/;#只引入ba ...
#!/usr/bin/perl
use 5.010;
package A;
$a = 10;
sub print_var{
$a += 10;
}
package B;
$a = 20;
package A;
say $A::a;
say &A::print_var();
say &{A::print_var}();
say "------通过符号引用的方式获取变量和函数------";
$pkg = 'A';
$varname = 'a';
$method_name = 'print ...
#!/usr/bin/perl
use 5.010;
say "-----------FreezeThaw模块------------------------";
#将复杂结构编码成可以打印的ASCII字符串,使用者可以将编码后的字符串发送到文件、DBM文件、数据库。
#use FreezeThaw qw(freeze thaw);#加载freeze()和thaw()
=pod
$c = {
'even' => [2,4,6,8],
'odd' => [1,3,5,7]
};
$obj = bless ('foo' => ...
#!/usr/bin/perl
use 5.010;
=pod
perl中表达式三种形式:
1、匹配:m/<regexp>;/mosxg cg
2、替换:s/<pattern>;/<replacement>;/mosxge g表示全部替换,而不是只替换首次出现的;e表示把<replacement>;当做一个运算符;
3、转化:tr/<pattern>;/<replacement>;/cds
=~ 表示匹配
!~ 表示不匹配
默认处理$_变量
=cut
my $str = & ...
#!/usr/bin/perl
use 5.010;
$line[19] = "hello";
#say $#line;
#标量变量的引用
$a += 2;
$ra = \$a;
$$ra += 2;
#say $$ra;
#say ${$ra};
#数组引用
@array = qw ( one two three four five );
$len = @array;
#say $len;#数组大小
$rarray = \@array;
#say $rarray;
$len = @$rarray;
#say $l ...
#coding=utf-8
import time
from splinter import Browser
def splinter(url,q,p):
browser=Browser('chrome')
#browser = Browser('webdriver.chrome')
#browser = Browser('webdriver.firefox')
browser.visit(url)
time.sleep(5)
#fill in account and p ...
#!/usr/bin/python
#-*-coding:utf-8-*-
import sys,time
nowtime = time.strftime("%Y-%m-%d %H:%M:%S")
number = int(time.strftime("%W"))+1
list1 = [0,1,2,3,4,5,6,7,6,5,4,3,2,1,0]
#print list.count(0)
#list2.extend(list)
#print list2
#print list2.index(0)
#list2.rev ...
#!/usr/bin/python
#-*-coding:utf-8-*-
import psycopg2
# 数据库连接参数
conn = psycopg2.connect(database="newdb", user="admin", password="admin", host="192.168.0.43", port="5432")
cur = conn.cursor()
cur.execute("CREATE TABLE test(id serial PRIM ...
#!/usr/bin/python
# -*-coding:utf-8-*-
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
import time
import pprint,pickle
import sys,os,glob,re,math,random
#from urllib2.request import urlopen
import smtplib
from array import array
from collections import deque
...
#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys,os,time
import ConfigParser
from _util import DEFAULT_DB_CONFIG_PATH
class Config:
def __init__(self):
self.path = DEFAULT_DB_CONFIG_PATH
self.cf = ConfigParser.ConfigParser()
self.cf.read(self.path)
def get ...
#!/usr/bin/python
# -*- coding:utf-8 -*-
import datetime,time
now = time.strftime('%Y-%m-%d %H:%M:%S')
print '当前时间:'+now
week = int(time.strftime('%W'))+1
print '当前周数:'+str(week)
#datetime >> string
now = datetime.datetime.now()
print 'datetime >> string: '+now.strf ...
1.安装jdk、ant、eclipse
2.下载源码
https://github.com/winghc/hadoop2x-eclipse-plugin.git
3.编译
进入到hadoop2x-eclipse-plugin-master\src\contrib\eclipse-plugin目录执行如下命令:
ant jar -Dversion=2.6.0 -Declipse.home=E:\eclipse -Dhadoop.home=C:\hadoop-2.6.0
在目录hadoop2x-eclipse-plugin-master\build\contrib\eclips ...
在文本分类中,假设我们有一个文档d∈X,X是文档向量空间(document space),和一个固定的类集合C={c1,c2,c3,...,cj},类别又称为标签.显然,文档向量空间是一个高纬度空间.我们把一堆打了标签的文档集合<d,c>作为训练样本,<d,c>∈X×C, ...
样本集如下:
DayOutlookTemperatureHumidityWindPlayTennisD1SunnyHotHighWeakNoD2SunnyHotHighStrongNoD3OvercastHotHighWeakYesD4RainMildHighWeakYesD5RainCoolNormalWeakYesD6RainCoolNormalStrongNoD7OvercastCoolNormalStrongYesD8SunnyMildHighWeakNoD9SunnyCoolNormalWeakYesD10RainMildNormalWeakYesD11SunnyMildNormalS ...