自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

我叫张大大爷的博客

搬砖小白的自我描述

  • 博客(75)
  • 收藏
  • 关注

原创 string类型的数据 索引值与直接赋值的问题

string索引值与累加的问题

2022-06-03 15:34:38 176

原创 信奥赛一本通:1149:最长单词2

#include <bits/stdc++.h>using namespace std;int main(){ int sum[600] = {0}, j = 1; string s; getline(cin,s); int len = s.length(); // 012340123010 // 05911 for(int i = 0; i < len-1; i++) .

2022-04-08 15:28:34 430

原创 奥赛一本通1102:与指定数字相同的数的个数

#include <bits/stdc++.h>using namespace std;int main(){ int arr[101] = {0}, x, n, m; cin >> n; for(int i = 0; i < n; i++) { cin >> x; arr[x]++; } cin >> m; cout << arr[m]; .

2022-04-08 15:25:30 278

原创 1141:删除单词后缀

信息学奥赛一本通

2022-02-23 16:05:29 742

原创 Codeblocks中两个项目的main.cpp如何实现函数互相调用?

2021-09-15 16:51:13 612

原创 C++ while(cin >> a) 解析

#include<bits/stdc++.h>using namespace std;int main(){ /* int a[100]; int sum = 0; while (cin >> a[sum]) { sum++; } for(int i = sum-2; i >= 0; i--) cout << a[i] << " "; */ .

2021-08-06 16:36:06 631

原创 2021-05-15

python 多继承问题问题描述:提示:为什么继承类调换位置就出错class Animal: #父类 def __init__(self,name,age,weight): self.name = name self.age = age self.weight = weight print("我叫%s,我今年%d岁了,我体重是%d斤" % (self.name,self.age,self.weight)) d

2021-05-15 11:48:45 70

原创 python 猜数字游戏

话不多说上代码"""人机猜数字游戏,程序随机生成一个[1000,9999]之间的数字,由玩家猜这四位数是多少。要求:玩家手动输入这四位数后,程序将猜对的数字以数字形式显示出来,猜错的数字以X显示出来,例如:程序随机生成的数字是1738,玩家输入的值为1839,则程序显示1X3X。直到猜对为止,并显示出猜的次数."""import randoma=random.randint...

2019-12-13 14:07:13 676

原创 python 判断输入的单词中的字母是否在键盘同一行

话不多说上代码,如果有更好的欢迎扣我"""判断输入的单词是否为电脑键盘同一行,"""list1 = ["qwertyuiop","asdfghjkl","zxcvbnm"]a = input("请输入单词")for x in range(3): flag = 0 for y in range(len(a)): if a[y] in list1[x]...

2019-12-13 14:04:10 621

原创 Code::Blocks IDE停止工作是什么鬼?

#include <iostream>using namespace std;int main(){ cout << "Hello world!" << endl; return 0;}输出hello world的简单代码,但是怎么会提示错误呢? 而且编译器的路径也配置了。求大佬们指教...路径配置:错误信...

2019-10-25 13:52:31 515

原创 C++ 判断输入年份为闰年

#include <iostream>using namespace std;int main(){ int a; cin >>a; if (a%100==0) { if (a%400==0) cout << a << "是闰年" << endl; ...

2019-10-05 13:55:16 1459

原创 C++,求出数字包含7或者能被7整除的数字

#include <iostream>#include <cmath>using namespace std;int main(){ int i,a,b,c,d,bcd,cd; for (i=7;i<=10;i++) { if (i%7==0) { cout << ...

2019-09-29 10:56:40 6651 1

原创 C++求10000以内的指数

#include <iostream>using namespace std;int main(){ int i,j; for (i=0;i<=10000;i++) { for (j=2;j<=i;j++) { if (i%j==0) { ...

2019-09-29 10:12:33 173

原创 C++ 割圆求π

#include <iostream>#include <cmath>#include <iomanip>using namespace std;int main(){ int c=6,d=2; int i=1; double m=1; while (i<15) { m=sqrt(2-...

2019-09-23 15:24:26 658

原创 C++ 比较两数的大小的三种方法

#include <iostream>using namespace std;int adds(int x, int y);int main(){ int a,b; a=20; b=10; cout << adds(a,b) << endl;}int adds(int x, int y){ if (...

2019-09-06 11:20:12 29910 2

原创 C++ 两个整数相除结果为什么不为小数?

#include <iostream>#include <iomanip>using namespace std;int main(){ int a=4; double b=2.0; cout << (float)a/b <<endl; return 0;}

2019-09-05 18:09:45 4826 2

原创 求解Vscode配置默认浏览器出现Open browser failed!! 问题

出现的问题是:Open browser failed!! Please check if you have installed the browser chrome correctly!用户配置:说明:我也设置了默认浏览器的路径了,还是报错! 求解...

2019-08-05 21:03:25 15717 8

原创 Python求1 2 4 7 11 16 22 29

"""1 2 4 7 11 16 22 29 0 1 2 3 4 5 6 70 1 1+01 2 1+12 4 1+1+23 7 1+1+2+34 11 1+1+2+3+45 16 1+1+2+3+4+5n ? 1+1+2+3+4+...+n-1Sn=1+n(n-1)/2数列中相邻两个数的差构成一个公差为1等差数列"""a...

2019-06-08 11:49:33 3115

原创 requests 编码问题

import requestsr = requests.get('http://www.baidu.com/')print(r.encoding)r.encoding = 'utf8'# print(r.text)print(r.content.decode('utf8'))# print(r.apparent_encoding)# print(r.text)这里说明一下t...

2019-02-03 13:38:51 246

原创 json()函数的讲解

import json# json.dumps 将 Python 对象编码成 JSON 字符串# json.loads 将已编码的 JSON 字符串解码为 Python 对象dic = {"name": 'zs'}res = json.dumps(dic)print(res, type(res))ret = json.loads(res)print(ret, type(r...

2019-01-23 09:54:32 7009

原创 python 正则 提取HTml标签文本内容的

方法一:import retitle = '&lt;a helf="www.baidu.com" title="河南省"&gt;你好&lt;/a&gt;'res = re.findall(r'&lt;a.*?&gt;(.*?)&lt;/a&gt;', title)print(res)方法二:

2019-01-23 09:43:02 16536

原创 Nginx部署搭建详解

说明: 用的是flask框架 创建的项目 app.py改为main.py先附上main.py的代码from flask import Flaskfrom flask import Flask, render_template, requestfrom flask import jsonifydef create_app(): app = Flask(__name__)...

2019-01-22 18:02:21 191

原创 mysql 删除字段中重复字段

 student表中有name的重复值,删除掉name中重复值select distinct name from studentdistinct的具体用法详情见: https://www.cnblogs.com/leonlee/p/6042461.html 

2019-01-22 10:33:21 257

原创 python 随机小数

import numpy as npimport randomprint(random.randint(1, 10)) # 生成1-10随机整数,包含10print(np.random.randn(4)) #生成4个小数 7[ 0.54414116 0.82107715 -0.43214879 -0.31025722] ...

2019-01-22 10:00:54 1554

原创 python 定义函数 返回值只取其中一个

def test(): return 1,2a, b = test()1 2a, _ = test()1 # 说明 a, _ = test() 中 返回的是一个int类型 后续可直接运算# a, b = test() 返回值是一个元组, 直接运算报错 ...

2019-01-12 15:09:00 18560

原创 去除b中不属于a元素

a = [1,3,4,6,7]b = [1,2,3,4,5,6,7,8,9]print([i for i in b if i not in a])[2, 5, 8, 9] 

2019-01-12 15:02:14 155

原创 提取URL中的内容

from urllib.parse import urlparsea = urlparse('https://www.jb51.net/article/139594.htm')print(dir(a))print(a.netloc)print(a.path)print(a.scheme)['__add__', '__class__', '__contains__', '_...

2019-01-12 14:47:12 868

原创 zip 用法 与循环相似用法

a = [1,2,3,4,5,6]b = [0.13,0.14,0.78,0.46,0.66]zip(a,b)Out[4]: &lt;zip at 0x7fe0d41a6388&gt;for i in zip(a,b): print(i) (1, 0.13)(2, 0.14)(3, 0.78)(4, 0.46)(5, 0.66)for i in range(...

2019-01-09 10:50:03 320

原创 两个列表相乘 找最大值坐标

import numpy as npa = [1,2,3,4,5,6]b = [0.13,0.14,0.78,0.46,0.66,0.78]aOut[19]: [1, 2, 3, 4, 5, 6]bOut[20]: [0.13, 0.14, 0.78, 0.46, 0.66, 0.78]a_array = np.array(a)b_array = np.array(b)res...

2019-01-09 10:49:11 591

原创 ubuntu 安装xlrd

pip install -i http://pypi.douban.com/simple --trusted-host pypi.douban.com xlrd 

2019-01-07 10:15:27 2055

原创 ubuntu下的抓包工具 Wireshark下载

1.安装,sudo apt-get install wireshark2.运行,sudo wireshark。注意:抓包需要root权限。具体下载流程: https://yq.aliyun.com/ziliao/461341

2019-01-04 11:59:02 1113

原创 scrapy 中的pipeleine.py文件解答

Itm pipeline 为项目管道, 当item生成时,它会自动被送到Item piplone进行处理,常用来:1,清理HTML数据2,验证爬取数据,检查爬取字段3,查看并丢弃重复的内容4,将爬取的结果保存到数据库实现Item Pipeline很简单,只需要定义一个类并实现process_item()方法即可,启动Item Pipeline后,Item Pipeline会自动...

2019-01-03 20:46:31 158

原创 scrapy 爬虫框架怎么爬去的数据怎么生成一个json文件

scrapy crawl min_spider -o min_spider.json说明:  我的爬虫名字为min_spider,这条命令会在当前文件夹下生成一个min_spider.json的文件class MinSpiderSpider(scrapy.Spider): name = 'min_spider' allowed_domains = ['baidu.c...

2019-01-03 20:02:17 609 1

原创 ubuntu redis 连接问题

关于在scrapy 里面的redis 连接不上的解决问题1找到redis文件 一般在etc下面2 进入redis文件里面 用vi打开 redis.conf 记得sudo打开3 更改里面的bind 改为0.0.0.0 保存退出(大概在70行)进入爬虫里面里面 更改settings里面的# 指定redis数据库的连接参数# REDIS_PASS是我自己加上的redis连接密...

2019-01-02 17:08:57 991

原创 Ubuntu中navicat Premium 界面乱码问题

第一步:   选择工具 点击选项 乱码看不懂的直接点击最后一个第二步:选择界面字体 中的 Noto Sans Mono CJK Regular 再点击确定  不要点击默认 如果上面还是不行的话  直接找到下载路径里面的  start_navicat 文件  用vi打开  直接修改编码格式第一步 vi start_navicat 修改里面的 export  LANG ="...

2018-12-27 15:23:17 772 1

原创 爬虫注意的两个HTML标签

&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;meta charset="utf-8"&gt; &lt;title&gt;before&lt;/title&gt; &lt;style&gt;p:before{ content:"让爬虫怎么爬取 -";}&lt;/style&am

2018-12-24 14:57:51 668

原创 python 根据标签名获取标签内容

import reimport jsonimport requestsfrom bs4 import BeautifulSoupimport lxml.htmlfrom lxml import etreeresult = requests.get('http://example.webscraping.com/places/default/view/Algeria-4')wi...

2018-12-20 16:15:37 7758

原创 Python Magic_Methods 魔法方法

# 无论输入任意key,都不会出错,并且value的值不会发生改变# 数学对象两个必须一样class TestMagic(object): def __init__(self,num): self.a = num def __setitem__(self, key, value): self.a = value def __geti...

2018-12-19 09:51:28 332

原创 Python zlib模块 出错问题

import zlibs = 'asdasdfahjklfsjkldfhoidsfsfswhqefrsndfsn lfnsfg hfoshaifgsdluikfga'zlib_s = zlib.compress(s)print(zlib_s)TypeError: a bytes-like object is required, not 'str'不知道哪里出错了, 在线急.......

2018-12-18 20:19:22 742

原创 爬取糗事百科的页面

import requestsclass QiuShiBaiKe(): def __init__(self): """ 初始化参数 """ self.url_bash = 'https://www.qiushibaike.com/imgrank/{}' self.headers = {"User-Age...

2018-12-18 16:23:52 176

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除