- 博客(25)
- 收藏
- 关注
原创 使用str.cat方法将字符串合并
关于字符串的合并,之前在不同章节中主要用到了四种方法:使用+(加号)组合字符串:例如输入X = 'a'+'b'能得到X的值是'ab' 使用%占位符做字符串组合,主要用在变量输出上,例如输入X = 'I am %s'%'Tony',能得到X的值是'I am Tony' 使用.join方法将多个可迭代的对象合并,例如输入X = ' '.join(['I','am','tony']),得到X的值...
2018-12-03 17:11:37
1712
原创 C# 操作Entities Framework进行增删该查
创建本地数据库 Players 表名 Table_1 /*using System;namespace StringApplication{ class Program { static void Main(string[] args) { //字符串,字符串连接 string fname, lname; fname = "Rowan"; lnam
2017-06-19 17:51:04
1256
原创 C# 操作本地SQL Server实现增删改查
VS2015 连接本地SQL Server using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Data; //引用 表的命名空间using System.Data.SqlClient;
2017-06-19 17:48:31
1004
原创 文本数据进行去重操作
# -*- coding: utf-8 -*-#原始数据去重import pandas as pdinputfile = 'pl.txt'outputfile = 'updata_pl.txt'data = pd.read_csv(inputfile, encoding = 'utf-8', header = None)l1 = len(data)data = pd.DataFrame(da
2017-04-08 16:38:43
1440
转载 在线教程爬下来转换成PDF文件
廖雪峰Python教程# coding=utf-8import loggingimport osimport reimport timetry: from urllib.parse import urlparse # py3except: from urlparse import urlparse # py2import pdfkitimport requestsf
2017-03-26 17:00:39
1138
原创 爬虫—图片 - Pixabay
https://pixabay.com/#coding : utf -8import requestsfrom lxml import etreeimport timeimport urllibdef Full_url(): full_link = [] for i in range(1,166): full_link.append("https://pixa
2017-03-26 16:40:34
1353
原创 Hexo博客添加图片、音乐、视频
Hexo博客添加图片、音乐、视频添加本地图片在\hexo\source目录下新建文件夹,命名为images或者其他你喜欢的名字,然后编辑你的md博文,插入下面的代码样式:例如我在D:\hexo\source\images放入了一个haha.jpg图片,然后写下:插入音乐比如网易云音乐,找到
2017-03-09 14:27:33
2341
1
原创 hexo 异常处理
异常内容FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.htmlTemplate render error: (unknown path) [Line 1, Column 12] unknown block tag: aplayer at
2017-03-09 11:37:54
1936
转载 Sql常见面试题
1. 用一条SQL 语句 查询出每门课都大于80 分的学生姓名name kecheng fenshu 张三 语文 81张三 数学 75李四 语文 76李四 数学 90王五 语文 81王五 数学 100王五 英语 90
2017-03-02 19:42:17
542
原创 python爬取w3cschool python练习实例100例
w3cschool python练习实例100例代码如下:# -*- coding: utf-8 -*-import requestsfrom bs4 import BeautifulSoup#content > p:nth-child(3) > strongfor page in range(1,101,1): url = "http://www.w3cschool.cn/python
2017-02-27 19:44:02
2833
原创 python---集合set常用方法和操作
集合是唯一项的无序集,集合不提供索引或切片操作,集合的长度可变,但放入里面的必须是不可变的。集合分为两种:可变集合(set)和不可变集合(frozenset)。 集合通用方法和操作 - len(s) 返回集合s的项目数s.copy() 返回集合s的一份副本s.difference(t) 求差集,返回在s中,但不在t中的项目s.intersection(t) 求交集,
2017-02-27 15:26:23
811
原创 python---字典dict的常用方法和操作
len(d) 返回字典d的项目数d[k] d中键k的值del d[k] 删除d[k]k in d 如果k 是 d 的键值,返回trued.clear() 清空dd.copy() 返回d的一个拷贝d.fromkeys(s[value]]) 返回一个新字典,S中的所有元素作为新字典的键,值为valued.get(k,[v]) 返回d[k],没有则返回vd.item
2017-02-27 15:08:41
624
原创 python---列表list常用方法
list(s) 将s转化为一个列表s.append(x) 将新元素x加到S的尾部s.extend(t) 将新列表t加到s的尾部s.count(x) 计算x出现的次数s.index(x[start[stop]]) 搜索X元素s.insert(i,x) 在i处添加xs.pop([i]) 弹出第i个元素,如果省略i弹出最后一个s.remove(x) 移除xs.revers
2017-02-27 14:51:23
752
原创 lg
python 爬取拉勾网职位信息详情职位描述for string in soup.body.dl.div.stripped_strings: print(string)这一步输出了我想要的内容 可是我需要把输出的内容写入到txt文件中去。“` f = open(“lg.txt”,’w’)for string in soup.body.dl.div.stripped_strings:
2017-02-23 20:48:16
689
原创 Python3常用内置函数
数学相关1.abs(a) : 求取绝对值。abs(-1)2.max(list) : 求取list最大值。max([1,2,3])3.min(list) : 求取list最小值。min([1,2,3])4.sum(list) : 求取list元素的和。 sum([1,2,3]) >>> 65.sorted(list) : 排序,返回排序后的list。6.len(lis
2017-02-23 17:58:39
545
原创 python 词云
# -*- coding: utf-8 -*-""""Masked wordcloud================Using a mask you can generate wordclouds in arbitrary shapes."""from os import pathfrom PIL import Imageimport numpy as npimport ma
2017-02-16 18:35:11
814
原创 python 词云 wordcloud
word_cloud 生成词云有两个方法。from text 和 from frequencies 。如果我们处理英文文档的话,就可以直接使用第一个方法,而不需要提前预处理文本,由于我们要做的是中文文本,所以我们必须自己分词,并处理为数组,使用第二种方法。# -*- coding: utf-8 -*-from os import pathfrom wordcloud import
2017-02-16 16:43:26
1344
原创 破解加密zip文件
#encoding:utf-8import zipfilefilename = "aaa.zip"#需要解压的压缩文件dictfile = "mima.txt"#密码文件,保存着多组密码password = open(dictfile,'r')#打开密码文件for i in password: file = zipfile.ZipFile(filename)
2017-01-02 18:50:32
3336
原创 第 0004 题:任一个英文的纯文本文件,统计其中的单词出现的个数。
# -*- coding:utf-8 -*-#第 0004 题:任一个英文的纯文本文件,统计其中的单词出现的个数。#python 3.5.2import collections,reimport sysdef cal(filename = 'aaa.txt'): f = open(filename,'r') data = f.read() dic = collections.
2016-12-31 16:17:47
878
原创 Python 练习册,每天一个小程序----------000 图片右上角加上红色的数字
# -*- coding:utf-8 -*-#第 0000 题:右上角加上红色的数字,类似于微信未读信息数量那种提示效果#python 3.5.2from PIL import Image, ImageDraw, ImageFontdef add_num(filepath, num = 1): image = Image.open('aaa.jpg') size = i
2016-12-31 13:07:26
1218
原创 Python 练习册,每天一个小程序----------001使用 Python 如何生成多位随机数
# -*- coding:utf-8 -*-#第 0001 题:**做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用**生成激活码**(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)import random, stringdef random_series(count, len = 10): str = 'abcdef
2016-12-30 19:45:10
997
原创 python3的input问题
python3 中input默认输入 的是str 类型,而python2中input默认输入int,float类型,也就是数字类型所以要想得到数字。类型转换成int即可。
2016-12-02 14:09:06
1294
原创 我的Python——————爬虫
系统 win10 64位Python版本号:3.4.3简单的爬取图片import urllib.res = urllib.request.urlopen("http://zhaduixueshe.com/static/pic/discovery.png")with open("xxx.png", "wb") as f:f.write(res.read())或者:
2016-11-18 08:47:52
304
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人