python数据库基本操作 操作关键字 创建连接 connect [kəˈnekt] 连接 实例化游标 cursor [ˈkɜːsə(r)] 游标 执行sql语句 execute [ˈeksɪkjuːt] 实行;执行; 提交修改 commit [kəˈmɪt] 做出 事务回滚 rollback [ˈrəʊlbæk] 回落; 关闭游标和链接 close 一、用脚本连接数据库: import pymysql #创建一个对象,用于连接数据库,参数分别设置为地址,用户名,密码,数据库,字符集 db = pymysql.connect(host = 'localhost',user='root',password='598941324',database='cuijianzhe',charset='utf8') #使用cursor方法创建一个游标对象,相当一个操作者 cursor = db.cursor() #编写下sql语句 sql = '''create table teacher( id int primary key auto_increment, name varchar(30), a.... python脚本操作数据库 Python
工具预览 Chrome浏览器,版本最好大于v71 chromedriver selenium 下载chromedriver 需要翻墙,地址为http://chromedriver.chromium.org/downloads,找到符合自己浏览器版本的chromedriver驱动,下载解压后,将chromedriver.exe文件放到Python目录下的Scripts目录下。我已下载75版本 安装selenium pip install selenium 有界面 # -- coding: utf-8 -- import time from selenium import webdriver from selenium.webdriver.common.keys import Keys #myusername = "XXX"#登录账号 #mypassword = "XXX"#登录密码 driver = webdriver.Chrome() #模拟浏览器打开网站 driver.get("https://hacpai.com/login") #driver.maximize_wind.... windows下实现黑客派自动签到 Python
****# 虽然没什么用,学习阶段,练手。 一、 爬取表情包 1、爬取斗图啦: import requests from bs4 import BeautifulSoup import threading glock = threading.Lock() headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36', 'Referer': 'https://hacpai.com/login'} class get_doutu(): def all_htmls(self): htmls = [] for i in range(1,10): url = "https://www.doutula.com/photo/list/?page=%s"%i res = requests.get(url,headers=headers) htmls.append(res.text) ret.... python爬虫实例 Python
两个月前需求:使用python3做一个将观测数据编译产出成bufr数据的一个工具 刚刚完成初版,其中的数据文件路径和数据内容格式还需要仔细核对,但整体逻辑已实现,剩下的工作时间可能会用来完善它 Anaconda3 The open-source Anaconda Distribution is the easiest way to perform Python/R data science and machine learning on Linux, Windows, and Mac OS X. With over 11 million users worldwide, it is the industry standard for developing, testing, and training on a single machine, enabling individual data scientists to: Quickly download 1,500+ Python/R data science packages Manage libraries, dependencie.... py项目中学到的知识梳理 Python
一、字符串、列表、元组、字典、集合练习 1.1 BMI计算输出 BMI指数(Body Mass Index) 以称身体质量指数 BMI值计算公式: BMI = 体重(公斤) / 身高的平方(米) 例如: 一个人69公斤,身高是173公分 BMI = 69 / 1.73**2 = 23.05 标准表: BMI < 18.5 体重过轻 18.5 <= BMI < 24 体重正常 BMI > 24 体重过重 要求: 输入身高的体重,打印出BMI的值并打印体重状况 #!/bin/python3 Height = float(input('请输入身高(米):')) Weight = float(input('请输入体重(公斤):')) BMI = Weight / Height **2 print('%.2f'%BMI) if BMI < 18.5: print('您的体重过轻,BMI值为:%.2f' %BMI) elif BMI < 24: print('您的体重正常,BMI值为:%.2f'%BMI) else: print('您的体重过重,BMI值为:%..... python练习题 Python
现在域名上面很多证书,需要一个强有力的工具去查看并且了解到期时间的状况然后告知你。 检测脚本下载地址: sslooker.kernel3.10.0.x8664.rar 使用方法: #!/bin/bash dir=/tmp/yuming data=date +%Y-%m-%d script=/usr/bin/sslooker yuming=cat /tmp/yuming for i in {yuming[*]} do hours=`echo -e "( script i 443 )" days=echo "hours/24"|bc` if [ "days" -lt "3" ]; then cat > /tmp/sendmail.py << ccc #!/usr/bin/env python3 import os import smtplib from email.mime.text import MIMEText from email.utils import formataddr my_sender = '598941324@qq.co.... 使用python发送邮件告知SSL证书到期时间 Python
python功能很强大,多系统多终端定制。 下面来一个定时任务在wondows上执行 话不多说,直接点 import os import time exe_name = input('请输入程序名称(模糊)\n') timing = input('多少分钟后打开\n') current_path = os.getcwd() files = os.listdir(current_path) exist = False for file_name in files: if exe_name in file_name: exe_name = file_name exist = True break if not exist: print('程序找不到') os._exit(0) else: time.sleep(int(float(timing)*60)) os.system('start {}{}'.format(current_path,exe_name)) 怎么用呢? 此py脚本放在需要打开文件或程序的当前文件夹或者盘符内,跨盘符或者跨文件夹可能不会成功,还有待完善 1、打开脚本 ...... 今天展示一个实用小脚本代码 Python