打包python文件成exe格式

1. 直接在命令行用pip安装 pyinstaller
pip install pyinstaller

2. 下载安装pyinstaler运行时所需要的windows拓展---pywin32
pywin32:http://sourceforge.net/projects/pywin32/files/pywin32/
点击最新的Build再点击pywin32-219.win-amd64-py2.7.exe(这里要根据你的windows x86或者x64和你的python版本来选择)

3.在命令行中切换到要打包的程序所在目录,直接输入下面的指令即可
pyinstaller -F -w demo.py

 

Via

取出多个文件夹里面的第一图片,并以文件夹命名

manga

Debian 8 install Python3.5.1

Debian 8 x64 (jessie)
python --version
sudo apt-get update

bash: sudo: command not found.
su -
apt-get install sudo

sudo apt-get update
dpkg -l python*

sudo apt-get install build-essential -y
sudo apt-get install libncurses5-dev libncursesw5-dev libreadline6-dev -y
sudo apt-get install libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev -y
sudo apt-get install libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev -y

sudo apt-get install libssl-dev openssl

wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
tar zxvf Python-3.5.1.tgz
cd Python-3.5.1
./configure --prefix=/usr/local/python35
make all
sudo make install

安装好后把 python3 添加到PATH里,打开~/.bashrc 文件,在最后添加:
$ vi ~/.bashrc
添加
export PATH=$PATH:/usr/local/python35/bin

echo "export PATH=$PATH:/usr/local/python35/bin" >> ~/.bashrc
cat ~/.bashrc
保存后:
source ~/.bashrc

python3 --version

sudo rm /usr/bin/python /usr/bin/python2
sudo ln -s /usr/local/python35/bin/python3.5 /usr/bin/python
sudo ln -s /usr/local/python35/bin/pip3 /usr/bin/pip
sudo pip install --upgrade pip
http://www.moguf.com/post/setuppython3

ubuntu运行ss客户端

pip install shadowsocks

apt-get install build-essential
wget https://github.com/jedisct1/libsodium/releases/download/1.0.12/libsodium-1.0.12.tar.gz
tar xf libsodium-1.0.12.tar.gz && cd libsodium-1.0.12
./configure && make -j2 && make install
ldconfig

sslocal -s server_ip -p server_port -l 1080 -k password -t 600 -m chacha20

-k 密码要加"双引号"

 

 

illegal multibyte sequence

UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 840: illegal multibyte sequence

#!/usr/bin/python3
# -*- coding:utf8 -*-
import codecs

然后指定解码方式:
open("filename",'w',encoding="utf8")

Windows 安装 64位 mysql

下载mysql-5.7.19-winx64,
1.以管理员身份打开CMD
2.进入解压目录
cd C:\mysql-5.7.19-winx64\bin
3.安装:
安装并初始化,记下初始密码
mysqld --initialize --user=mysql --console

A temporary password is generated for root@localhost: hs/sIrK3g%tB
安装服务
mysqld -install
启动服务
net start mysql

修改默认密码和数据库的字符集:
mysql -u root -p
mysql> alter user root@localhost identified by "12345";
mysql> set character_set_client=utf8;
......
查看数据库的字符集是否全部为utf8
mysql> show variables like 'character%';

+--------------------------+----------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | utf8 |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | C:\mysql-5.7.19-winx64\share\charsets\ |
+--------------------------+----------------------------------------+
8 rows in set, 1 warning (0.00 sec)

mysql> exit;

Python 3.5无法通过pip 直接安装Mysqldb

去第三方非官方库下载mysqlclient-1.3.10-cp35-cp35m-win_amd64.whl

http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient

pip install mysqlclient-1.3.10-cp35-cp35m-win_amd64.whl

C:\mysql-5.7.19-winx64>pip install mysqlclient-1.3.10-cp35-cp35m-win_amd64.whl
Processing c:\mysql-5.7.19-winx64\mysqlclient-1.3.10-cp35-cp35m-win_amd64.whl
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.3.10

DHT磁力链接搜索引擎 python编写

cd /home
tar zxvf zsky.tar.gz
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl stop iptables.service
systemctl disable iptables.service
setenforce 0
sed -i s/"SELINUX=enforcing"/"SELINUX=disabled"/g /etc/sysconfig/selinux
cd zsky
yum -y install wget gcc gcc-c++ python-devel mariadb mariadb-devel mariadb-server
yum -y install epel-release python-pip redis
pip install -r requirements.txt
pip install redis
systemctl start mariadb.service
systemctl enable mariadb.service
systemctl start redis.service
systemctl enable redis.service
mysql -uroot -e"create database zsky default character set utf8mb4;"
python manage.py init_db
#建表
python manage.py create_user
#按照提示输入用户名、密码、邮箱
nohup gunicorn -k gevent --access-logfile zsky.log --error-logfile zsky_err.log manage:app -b 0.0.0.0:80 --reload>/dev/zero 2>&1&
#开启网站访问,访问日志是当前目录下zsky.log,错误日志是当前目录下zsky_err.log
#如果不想要日志 就运行下面这条命令
#nohup gunicorn -k gevent manage:app -b 0.0.0.0:80 --reload>/dev/zero 2>&1&
nohup python simdht_worker.py >/dev/zero 2>&1&

#开机自启动
chmod +x /etc/rc.d/rc.local
echo "systemctl start mariadb.service" >> /etc/rc.d/rc.local
echo "systemctl start redis.service" >> /etc/rc.d/rc.local
echo "cd /home/zsky" >> /etc/rc.d/rc.local
echo "nohup python simdht_worker.py >/dev/zero 2>&1&" >> /etc/rc.d/rc.local
echo "nohup gunicorn -k gevent manage:app -b 0.0.0.0:80 --reload>/dev/zero 2>&1&" >> /etc/rc.d/rc.local

ps -ef|grep python
kill -9 xxx
python simdht_worker.py

 

0 * * * * ps -ef | grep "python simdht_worker.py" | grep -v grep | awk '{print $2}' | xargs kill -9
1 * * * * cd /root/zsky/ && python simdht_worker.py

zsky.tar

 

/usr/bin/mysqldump  -u root -p zsky | gzip > /root/zsky.sql.gz

 

win7安装MongoDB

下载mongodb-win32-x86_64-2.4.5.zip这个版本

解压至C盘,并建立C:\mongodb\DB文件夹和C:\mongodb\log\log.txt文件

管理员模式运行CMD

cd mongodb\bin\

mongod.exe --logpath=C:\mongodb\log\log.txt --dbpath=C:\mongodb\data\db

mongod.exe --install --logpath=C:\mongodb\log\log.txt --dbpath=C:\mongodb\data\db

net start mongodb 启动mongodb服务

sc delete MongoDB 删除mongodb服务

启动后,再到命令行输入

mongo

如果成功的进入mongo的shell环境,那么就说明MongoDB已经安装成功了

 

列表解析式

运行结果

['http://www.hostloc.com/forum-45-1.html', 'http://www.hostloc.com/forum-45-2.html', 'http://www.hostloc.com/forum-45-3.html', 'http://www.hostloc.com/forum-45-4.html', 'http://www.hostloc.com/forum-45-5.html', 'http://www.hostloc.com/forum-45-6.html', 'http://www.hostloc.com/forum-45-7.html', 'http://www.hostloc.com/forum-45-8.html', 'http://www.hostloc.com/forum-45-9.html', 'http://www.hostloc.com/forum-45-10.html', 'http://www.hostloc.com/forum-45-11.html', 'http://www.hostloc.com/forum-45-12.html', 'http://www.hostloc.com/forum-45-13.html', 'http://www.hostloc.com/forum-45-14.html']

自写的第一个爬取图片实例

老套的爬图片实例,陆续写了几天,不容易,终于出来了。

难点有:分别为图片创建文件夹,爬取时不惧怕防盗链。

没有定义函数 比较难看,哈哈

运行结果如下:

%e6%8d%95%e8%8e%b7