06 2020 档案

摘要:字符串.splitlines( ) 分隔 '\r\n' 和 '\n' 字符串.lstrip('字符') 删除左侧的字符,全部删除 字符串.strip('字符') 删除左右两侧的字符 字符串.title( ) 将每一个单词的首字母大写 2020-06-30 阅读全文
posted @ 2020-06-30 13:01 Hany47315 编辑
摘要:#去掉x轴 plt.xticks([]) #去掉y轴 plt.yticks([]) #去掉坐标轴 plt.axis('off') 2020-06-26 阅读全文
posted @ 2020-06-26 09:41 Hany47315 编辑
摘要:#coding=gbk import math m = int(input()) n = int(input()) print(math.gcd(m,n)) # 最大公约数 print((m*n)//math.gcd(m,n)) # 最小公倍数 将字符串 s="alex" 转换成列表 list(s) 阅读全文
posted @ 2020-06-24 20:26 Hany47315 编辑
摘要:DataFrame对象是一个表格型的数据结构 DataFrame对象的列是有序的 DataFrame对象列与列之间的数据类型可以互不相同 文件写操作时,writelines方法的参数可以是列表 元组 字典 wordcloud.WordCloud()函数中的参数mask是用来设置 词云的遮罩形状 pa 阅读全文
posted @ 2020-06-21 20:03 Hany47315 编辑
摘要:#coding=gbk from operator import add # 导入加法 # map 函数名 , 序列对象 print(list(map(str,range(5)))) print(list(map(len,['abc','1234']))) # [3, 4] for num in m 阅读全文
posted @ 2020-06-21 10:05 Hany47315 编辑
摘要:''' 第一页 https://tieba.baidu.com/f?kw=python&ie=utf-8&pn=0 # 第二页 https://tieba.baidu.com/f?kw=python&ie=utf-8&pn=50 # 第三页 https://tieba.baidu.com/f?kw= 阅读全文
posted @ 2020-06-20 19:53 Hany47315 编辑
摘要:https://www.cnblogs.com/hany-postq473111315/p/12765835.html https://www.cnblogs.com/hany-postq473111315/p/12765847.html https://www.cnblogs.com/hany-p 阅读全文
posted @ 2020-06-20 17:20 Hany47315 编辑
摘要:移动 .crx 插件无法安装问题 解决方案: 修改后缀名为 .zip 文件 进行解压后,使用浏览器扩展程序加载已解压的文件进行扩展 添加插件 2020-06-20 阅读全文
posted @ 2020-06-20 13:09 Hany47315 编辑
摘要:ages = 20 ticketPrice = 20 if ages >= 16 else 10 count = 8 print( count if count % 10 == 0 else "不能被10整除") 成立条件时执行的语句 if 条件 else 不成立时执行的语句 2020-06-19 阅读全文
posted @ 2020-06-19 23:52 Hany47315 编辑
摘要:from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return "Hello Flask" @app.route('/index') def index(): return "Hello 阅读全文
posted @ 2020-06-19 10:21 Hany47315 编辑
摘要:输入列表或者字典时使用eval可以自动转换为其类型 2020-06-18 阅读全文
posted @ 2020-06-18 20:49 Hany47315 编辑
摘要:重置spyder 解决 gbk 编码不能读取问题 2020-06-18 阅读全文
posted @ 2020-06-18 20:44 Hany47315 编辑
摘要:https://www.cnblogs.com/zhangxinqi/p/9231801.html 2020-06-15 阅读全文
posted @ 2020-06-15 13:59 Hany47315 编辑
摘要:string = input().split() dic = {} for i in string: dic[i] = dic.get(i,0) + 1 dic = sorted(dic.items(), key=lambda x: x[1],reverse=True) for key,value 阅读全文
posted @ 2020-06-13 17:39 Hany47315 编辑
摘要:在第一行加入 # coding=utf-8 2020-06-13 阅读全文
posted @ 2020-06-13 12:48 Hany47315 编辑
摘要:爬取自己博客曾经发布过的所有标题 import csv import requests from bs4 import BeautifulSoup # https://www.cnblogs.com/hany-postq473111315/ # https://www.cnblogs.com/han 阅读全文
posted @ 2020-06-10 18:23 Hany47315 编辑
摘要:sorted(字典名.items(), key=lambda x: x[1]) x = a[a['列名'] == 值]['列名'] y = a[a['列名'] == 值]['列名'] dic_xy = dict(zip(x,y)) lst_xy = sorted(dic_xy.items(), ke 阅读全文
posted @ 2020-06-09 19:43 Hany47315 编辑
摘要:plt.xticks(rotation = 45) 2020-06-07 阅读全文
posted @ 2020-06-07 21:49 Hany47315 编辑
摘要:启发: 1.可以使用系统给出的方法,就不要自己去创建判断,效率可能会降低很多 2.使用一个变量不能解决问题,那就创建多个变量 3.找准数据类型,只要数据是这种数据类型,那么它就具有这个数据类型应该具有的方法,如果没有你需要的,那么就进行强制转换. 4.使用字典存储值,可以将两个序列对象的格式进行自定 阅读全文
posted @ 2020-06-07 20:07 Hany47315 编辑
摘要:base = [str(x) for x in range(10)] + [chr(x) for x in range(ord('A'), ord('A') + 6)] # ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C 阅读全文
posted @ 2020-06-07 11:19 Hany47315 编辑
摘要:nums = [] lst = [i for i in range(101)] l = [] for j in range(2,101): # 将质数加入到 l 中 temp = 1 for i in range(2,j-1): if lst[j] % i == 0: temp = 0 if tem 阅读全文
posted @ 2020-06-07 11:16 Hany47315 编辑
摘要:dic = {'0':0} for i in range(1000): if i % 3 == 0 and i %5 == 0 and i % 10 != 0: dic['0'] += 1 print("1000以内能被3或5整除但不能被10整除的数的个数为:",dic['0']) 使用字典的键 作 阅读全文
posted @ 2020-06-07 11:12 Hany47315 编辑
摘要:def min_max_sum(num): num = list(num) Min = min(num) Max = max(num) Sum = sum(num) num.remove(Min) num.remove(Max) tup = [] tup.append(Min) tup.append 阅读全文
posted @ 2020-06-07 11:10 Hany47315 编辑
摘要:def factor(n): nums = [ ] for i in range(1,n+1): if n % i == 0: nums.append(i) print(n,"的因子有:",nums) print("所有因子的和为: ",sum(nums)) while True: num = in 阅读全文
posted @ 2020-06-07 11:08 Hany47315 编辑
摘要:读取数据,下载数据到 csv 文件中 allUniv 列表类型[[...],[...]] 字符集编码使用 utf-8-sig with open('文件名.csv','w',newline='',encoding='utf-8-sig') as fout: write = csv.writer(fo 阅读全文
posted @ 2020-06-06 15:12 Hany47315 编辑
摘要:fig,subs = plt.subplots(2,2) subs[0][0].plot(data_math_C1) subs[0][0].set_title('C_1 曲线') subs[0][1].plot(data_math_C2) subs[0][1].set_title('C_2 曲线') 阅读全文
posted @ 2020-06-06 11:52 Hany47315 编辑
摘要:plt.axhline(y=0,ls=":",c="yellow")#添加水平直线 plt.axvline(x=4,ls="-",c="green")#添加垂直直线 2020-06-05 阅读全文
posted @ 2020-06-05 12:27 Hany47315 编辑
摘要:plt.plot 内只有一个列表示例 import matplotlib.pyplot as plt lst = [4.53,1.94,4.75,0.43,2.02,1.22,2.13,2.77] plt.plot(lst) plt.rcParams['font.sans-serif']=['Sim 阅读全文
posted @ 2020-06-05 10:17 Hany47315 编辑
摘要:1.打开网页 urllib.request.urlopen('网址') 例:response = urllib.request.urlopen('http://www.baidu.com/') 返回值为 <http.client.HTTPResponse object at 0x00000224EC 阅读全文
posted @ 2020-06-04 14:47 Hany47315 编辑
摘要:安装驱动 python -m pip install mysql-connector 导包 import mysql.connector mydb = mysql.connector.connect( host="localhost", # 数据库主机地址 user="root", # 数据库用户名 阅读全文
posted @ 2020-06-03 15:59 Hany47315 编辑
摘要:打印元信息,基本上都会打印出来 类字典结构的 key 键 允许重复 get 请求可以传参,但是长度有限制 最大不能超过 2K post 文件上传使用 get 参数 默认放在网址中 post 在请求体中 post 请求可以获取 get 请求参数 类字典结构: <QueryDict> 键可以重复 字典结 阅读全文
posted @ 2020-06-03 10:45 Hany47315 编辑
摘要:导包 import numpy as np 创建二维数组 x = np.matrix([[1,2,3],[4,5,6]]) 创建一维数组 y = np.matrix([1,2,3,4,5,6]) x 的第二行第二列元素 x[1,1] 矩阵的乘法 x*y # 相关系数矩阵,可使用在列表元素数组矩阵 # 阅读全文
posted @ 2020-06-03 10:01 Hany47315 编辑
摘要:导包 import pandas as pd 设置输出结果列对齐 pd.set_option('display.unicode.ambiguous_as_wide',True) pd.set_option('display.unicode.east_asian_width',True) 创建 从 0 阅读全文
posted @ 2020-06-03 00:05 Hany47315 编辑
摘要:# 导入re模块 import re # 使用match方法进行匹配操作 result = re.match(正则表达式,要匹配的字符串) # 如果上一步匹配到数据的话,可以使用group方法来提取数据 result.group() re.match用来进行正则匹配检查 若字符串匹配正则表达式,则m 阅读全文
posted @ 2020-06-02 16:24 Hany47315 编辑
摘要:# bin2dec # 二进制 to 十进e5a48de588b662616964757a686964616f31333335336437制: int(str,n=10) def bin2dec(string_num): return str(int(string_num, 2)) # hex2de 阅读全文
posted @ 2020-06-02 14:00 Hany47315 编辑
摘要:pip install 包名 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com 一定要指定 信任豆瓣源,不然就算换了源 也可能会失败 2020-06-02 阅读全文
posted @ 2020-06-02 12:46 Hany47315 编辑
摘要:在读取文件时,进行字符转吗 f = open("out.html","w",encoding='utf-8') 2020-06-01 阅读全文
posted @ 2020-06-01 11:08 Hany47315 编辑

点击右上角即可分享
微信分享提示