windows下安装scrapy
其实也没啥
安装好python后执行
pip install scrapy但是这样一般情况下会有一个依赖包安装不好
运行下面这句话就可以了
easy_install lxml如果运行的时候还是报错的话
可能需要装一下win32api
在这里
其实也没啥
安装好python后执行
pip install scrapy但是这样一般情况下会有一个依赖包安装不好
运行下面这句话就可以了
easy_install lxml如果运行的时候还是报错的话
可能需要装一下win32api
在这里
go语言中的struct定义方式与C语言类似
type Human struct {
Name string
Age int
}同时go语言还支持匿名字段(嵌入字段)的定义
type Student struct {
Human
Grade int
}上述代码中的Human就是一个匿名字段,这个功能相当于其他语言中的继承
只要Human字段嵌入到了Student中,那么Student就默认包含了Human的所有字段
可以采用这种方式来赋值
student := new(Student)
student.Name = "小明"
student.Age = 18也可以采用这样的方式
student := new(Student)
human := new(Human)
human.Name = "小明"
human.Age = 18
student.Human = human新的开始,继续努力!
闲来无事把周五商老板说的面试题解了一下
具体代码如下(Golang)
package main
import (
"fmt"
)
const SIZE = 6
var a = [SIZE][SIZE] int {
{2, 2, 3, 3, 5, 6},
{2, 1, 3, 3, 4, 6},
{2, 2, 2, 1, 1, 6},
{1, 2, 4, 4, 5, 5},
{2, 2, 2, 1, 1, 5},
{1, 4, 4, 1, 3, 3},
}
var count int = 0 // 计数
var mark = [SIZE][SIZE] int {} // 用来标记该数字是否被遍历过
func main() {
fmt.Println("原数据:", "\n")
lenA := len(a);
for i := 0; i < lenA ; i++ {
fmt.Println(a[i])
}
fmt.Println("\n计算结果:")
for i := 0; i < lenA; i++ {
lenX := len(a[i])
for j := 0; j < lenX; j++ {
if mark[i][j] == 0 {
findSame(i, j, a[i][j])
count ++
}
}
}
fmt.Printf("共%d个簇\n\n", count)
fmt.Println("具体情况如下:\n")
lenMark := len(mark)
for i := 0; i < lenMark ; i++ {
fmt.Println(mark[i])
}
}
func findSame(i, j, x int) {
tempI := i
tempJ := j
if mark[i][j] == 0 {
mark[i][j] = count + 1
// 往上找相同的数
for {
i--
if i < 0 || a[i][j] != x {
break
}
findSame(i, j, a[i][j])
}
// 往下
i = tempI
for {
i++
if i > SIZE - 1 || a[i][j] != x {
break
}
findSame(i, j, a[i][j])
}
// 往左
i = tempI
for {
j--
if j < 0 || a[i][j] != x {
break
}
findSame(i, j, a[i][j])
}
// 往右
j = tempJ
for {
j++
if j > SIZE - 1 || a[i][j] != x {
break
}
findSame(i, j, a[i][j])
}
}
}经商老板指点,findSame中的for循环没必要。下面是改过之后的findSame
func findSame(i, j, x int) {
if mark[i][j] == 0 {
mark[i][j] = count + 1
// 往上找相同的数
if i-1 >= 0 && a[i-1][j] == x {
findSame(i-1, j, a[i-1][j])
}
// 往下
if i+1 < SIZE && a[i+1][j] == x {
findSame(i+1, j, a[i+1][j])
}
// 往左
if j-1 >= 0 && a[i][j-1] == x {
findSame(i, j-1, a[i][j-1])
}
if j+1 < SIZE && a[i][j+1] == x {
findSame(i, j+1, a[i][j+1])
}
}
}对递归理解还是不够到位啊~不过现在应该OK了^_^
今天刷票,没想到公司ip被12306封了,看到鱼大的刷票软件支持socks5代理,于是想到用服务器搞个代理试试。
步骤如下
apt-get install dante-servermkdir /var/log/sockd修改配置文件 vi /etc/danted.conf 写入以下内容
logoutput: /var/log/sockd/sockd.log
internal: 服务器ip port = 1080
external: 服务器ip
method: username none
user.privileged: proxyuser
user.notprivileged: nobody
user.libwrap: nobody
client pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
log: connect disconnect
}
pass {
from: 0.0.0.0/0 to: 0.0.0.0/0 port gt 1023
command: bind
log: connect disconnect
}
pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
command: connect udpassociate
log: connect disconnect
}
block {
from: 0.0.0.0/0 to: 0.0.0.0/0
log: connect error
}/etc/init.d/danted startnetstat -anp | grep 1080有个问题就是端口暴露出来 会被各种人扫到。。所以千万不能一直开着