Tilo Mitra's avatar

链家网站爬取

import requestsimport pandas as pdfrom lxml import etreeimport timefrom multiprocessing.dummy import Poolstart = time.time()title = []house = []place = []rent = []area = []direction = []distinguish = []detail = { "标题": title, "房屋户型": house, "位置": place, "月租金": rent, "面积": area, ...

Tilo Mitra's avatar

SyntaxError: unexpected EOF while parsing错误

SyntaxError: unexpected EOF while parsing错误原因eval(str)的字符串为空就会报错解决读取文件时删除多余的空格

Tilo Mitra's avatar

requests.exceptions.InvalidHeader: Invalid return character or leading space in header: User-Agent错误

requests.exceptions.InvalidHeader: Invalid return character or leading space in header: User-Agent错误原因是分号后面的双引号多了个空格多个空格的headers头headers = { "User-Agent":" Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36"}正确headers头headers =...

Tilo Mitra's avatar

pip豆瓣安装源下载库文件

pip install -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com django==1.11.1

Tilo Mitra's avatar

串口测试案例

import timeimport serialcmd0 = b'defaultconfig\r\n'cmd1 = b'login 0 admin 12345678\r\n'cmd2 = b'newuser 1 config 12345678\r\n'cmd3 = b'exit\r\n'cmd4 = b'login 1 config 12345678\r\n'cmd5 = b'ifconfig eth0 192.168.3.4\r\n'cmd6 = b'addrule f 0 0.0.0.0 0.0.0.0 0 0.0.0.0 0.0.0.0 0 0 2\r\n'cmd7 = b'add...

Tilo Mitra's avatar

串口超级命令行

import serialfrom serial.tools import list_portstimex = 0.5ls = [115200,19200,9600]while 1: try: port_list = list(list_ports.comports()) if len(port_list) == 0: input("无可用串口,按回车键刷新串口列表...") continue else: while 1: lis = [] ...

Tilo Mitra's avatar

文件的上传校验

使用线程池开多线程会出错服务端.pyimport hashlibimport randomimport socketserverimport structimport jsonimport osimport threadingfrom configparser import ConfigParserclass Myserver(socketserver.BaseRequestHandler): def get_md5(self, file_size, file_path): md = hashlib.md5() read_size = 0 ...

Tilo Mitra's avatar

python文件打包

下载pyinstallerpip install pyinstaller最后,打包文件D:\>pyinstaller -F run.py #文件的绝对路径

Tilo Mitra's avatar

字体颜色

红色显示print("\u001b[31m hello world!")背景颜色显示print("\u001b[42;37;5m hello world!")重置属性设置print("\u001b[34;1m hello world! \u001b[0m") print("\u001b[41;37m hello \u001b[0m \u001b[32;4m world! \u001b[0m")颜色集for i in range(0, 16): line = "" for j in range(0, 16): code = str(i * 16 + j) ...

下一页  

湘ICP备19016894号 © 2019 小钱