Tilo Mitra's avatar

邮件发送

import yagmaildef send_email(contents,send_to = 'xx@qq.com'): #send_to 接收人 #登录邮箱,设置登录的账号,密码和port等信息 yag = yagmail.SMTP(user = 'xx@163.com',password = 'xx', host = 'smtp.163.com') #user发送人 #登录完即可一件发送,设置发送给谁,和邮件主题,邮件内容 yag.send(to = send_to, subject = '...

Tilo Mitra's avatar

文件夹和文件操作

#递归删除当前目录下所有文件(不包括目录)# import os# def filedir(Infile):# if os.path.isdir(Infile):# for file in os.listdir(Infile):# path = os.path.join(Infile,file)# filedir(path)# if os.path.exists(Infile):# try:# os.rmdir(Infile)# ...

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 ...

下一页  

湘ICP备19016894号 © 2019 小钱