python
tomjimn
这个作者很懒,什么都没留下…
展开
-
将MYSQL数据库中指定字段数据批到导出存入文件
1、应用场景:数据库表名为年月日结构。根据查找内容导出特定字段的数据。import calendarimport pymysqldef mysql_db(data): db_mysql = pymysql.connect(host="127.0.0.1", user="root", password='root', db='db', charset="utf8") cursor_db_mysql = db_mysql.cursor() cursor_db_mysql.exec原创 2021-06-26 13:19:18 · 145 阅读 · 1 评论 -
centos7安装python3虚拟环境
1.首先安装虚拟环境: pip3 install virtualenv2.安装虚拟环境扩展包: pip3 install virtualenvwrapper3.修改家目录下的配置文件.bashrc,:~/.bashrc添加如下内容:export WORKON_HOME=$HOME/.virtualenvssource /usr/local/bin/virtualenvwrapper.sh4.创建虚拟环境::mkvirtualenv -p python3 虚拟环境名称5.退出虚拟环境:dea原创 2021-01-19 14:57:03 · 370 阅读 · 0 评论 -
siege 压测
1.post提交 from表单siege -c 1 -r 200 “http://xxxxxxxx POST uid=xxx&src=xxx&…”2.post提交jsonsiege -c 10 -r 200 “http://xxxxx POST {“uid”:“xxxx”,“src”:“xxxx”,…}”测试结果:原创 2021-01-14 09:34:11 · 131 阅读 · 0 评论 -
python如何把python项目部署到linux服务器上
python如何把python项目部署到linux服务器上一、实施步骤1.1、安装python3开始安装之前先看一下机器的环境,主要看一下操作系他的环境和python版本。查看环境操作系统:[root@reportweb]# cat /etc/redhat-releaseCentOS release 6.5 (Final)查看python版本:[root@reportweb]# python -VPython 2.6.6[root@reportweb]# python3 -V-ba转载 2020-12-22 10:39:28 · 1145 阅读 · 0 评论 -
第一次尝试做爬虫!
今天尝试准备写个爬虫,在网上找了些图片网站,发现这个网站页面规则简单,就决定用他做处女作吧。该网站图片命名规则就是xxx1.jgp-xxx100.jpg:import requestsimport timeimport osfrom bs4 import BeautifulSouptp = 'E:\\tp'if not os.path.exists(tp): os.mkdir(tp)headers = {'User-Agent':' Mozilla/5.0 (Windows NT 6原创 2020-06-24 17:51:39 · 250 阅读 · 0 评论 -
python练习 4 九九乘法表
一、`a = (1,2,3,4,5,6,7,8,9)x = 0 for i in a: for h in a[x:10]: z = i * h print("%d ×%d = %d \t"%(i,h,z),end ="") print() x += 1 二、for i in range(1,10): for h in range(i,10): z = i * h print("%原创 2020-06-21 19:29:07 · 147 阅读 · 0 评论 -
python习题3:输入某年某月某日,判断这一天是这一年的第几天?
year = int(input('请输入年:'))mouth = int(input('请输入月:'))day = int(input('请输入日:'))if year % 4 == 0 or year % 400 == 0: feb = 29else: feb = 28mouth_day = [0,31,feb,31,30,31,30,31,31,30,31,30,31]sum =0for i in mouth_day[0:mouth]: sum = sum +原创 2020-06-20 12:59:01 · 8174 阅读 · 3 评论 -
python 题目2:企业发放的奖金根据利润来确定提成比例。
自己写的,太繁琐i = float(input("请输入当月利润:"))p = 0 if i <= 10: p = i * 0.1 print("应发放奖金总数为 %0.2f 万元:"% p)elif i > 10 and i < 20: p = 10 * 0.1 + (i - 10) * 0.075 print("应发放奖金总数为 %0.2f 万元:"% p)elif i >= 20 and i < 40:原创 2020-06-11 15:46:22 · 1781 阅读 · 0 评论 -
python 习题:有1,2,3,4个数字,能组成多少个互不相同且无重复数字的三位数,分别是那些数?
这道题想了半天,知道用for循环,没想用嵌套的方式。还是参考了别人的答案#for循环嵌套total = 0for units in range(1,5): #个位 for tens in range(1,5): #十位 for hundreds in range(1,5): #百位 if units != tens and tens != hundreds and units != hundreds: sum = hu原创 2020-06-11 14:25:06 · 3326 阅读 · 0 评论 -
python 自学 倒计时
from datetime import datetimeimport timedef date_now():“定义当前时间函数”now_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S") #获取当前时间return now_datedef date_delta(end_date):“计算离结束时间时间差函数”while 1:date_now()time.sleep(1) #每秒执行一次date_now函数now_date = da原创 2020-06-10 14:34:24 · 280 阅读 · 1 评论