自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(36)
  • 资源 (2)
  • 收藏
  • 关注

原创 迭代器

标准的迭代器接口有两个方法:__next__:返回一个可用元素,没有的时候抛出stoplteration异常__iter__:返回self,以便在应该使用可迭代对象的地方使用迭代器,例如for循环中。class eg: def __init__(self,text): self.text = text self.sub_text = text....

2020-01-07 22:58:59 163

原创 功能性模块 提取句子的每一个单词

class word: def __init__(self,text): self.text = text self.sub_text = text.split(" ") def __getitem__(self,index): if self.sub_text[index].isalpha(): retur...

2020-01-07 22:22:27 216

原创 功能性代码块 *kwargs 和 **kwargs

# #插入操作# s = []# def insert():# a = 0# while a < 4:# values = input("enter a world: ")# s.append(values)# a += 1# print(s)# insert()# # #加强版# s = ...

2020-01-07 11:40:44 200

原创 jupyter notebook basic for python (other)

# def p(a):# d = a + " " + a# return d# print(p("new days"))# type(print("did again"))# ## def twogril(one,two):# result = "I love " + one.title() + " " + two.title()# # print(result)# ...

2020-01-07 11:38:47 245

原创 简单代码引申出来的思考

#原代码,判断帽子的颜色def hat_available(color): hat_colors = 'black, red, blue, green, white, grey, brown, pink' return(color.lower() in hat_colors)have_hat = hat_available('green') print('hat ava...

2020-01-06 15:19:24 179

原创 jupyter notebook for python (八)

Functions Arguments & ParametersFunctions are used for code tasks that are intended to be reusedPython allows us to createUser Defined Functionsand provides manyBuilt-in Functionssuch asp...

2020-01-06 00:32:54 119

原创 jupyter notebook for python (七)

(1)String formatting methodsthe following methods are applied to string objects.capitalize()- capitalizes the first character of a string .lower()- all characters of a string are made lowerca...

2020-01-06 00:17:36 205

原创 jupyter notebook for python (六)

Boolean string testsmethods.isalpha() .isalnum() .istitle() .isdigit() .islower() .isupper() .startswith()typestrhas methods that return a Boolean (True or False) for different tests on t...

2020-01-06 00:02:33 92

原创 jupyter notebook for python (六)

(1)function input()(2)note:input()returns a string (type = str) regardless of entryif a string is enteredinput()returns a string if a number is enteredinput()returns a string[ ]...

2020-01-05 16:44:32 136

原创 jupyter notebook for python (五)

print() character art:# the letter 'A'print(" *")print(" * *")print(" *****")print(" * *")print("* *")print() * * * ***** * ** *# create # [ ...

2020-01-05 16:21:18 108

原创 jupyter notebook for python (四)

(一)Addition: Numbers and StringsNumeric additionNumeric additionSingle linemath equations, run in a code cell, will output a sum# adding a pair of single digit Integers3 + 5 String additi...

2020-01-05 16:14:14 169

原创 jupyter notebook for python (三)

(一)内置函数的简单使用Using the Pythontype()functiontype()returns the data type of python objectsstr,int,floatWhat does usingtype()reveal?str: whentype()returnsstrthat means it has evaluate...

2020-01-05 10:58:24 139

原创 jupyter notebook for python (二)

(一)字符串(string):A String is a commontypeof data, used in programming, consisting of a sequence of 1 or more characters.A String is a sequence of characters(aka: astringof characters) Chara...

2020-01-05 10:23:05 181

原创 jupyter notebook (一)

(一)如何运行:Click in the cell belowandpress "Ctrl+Enter"to run the code or Click in the cell belowandpress "Shift+Enter"to run the code and move to the next cell Menu: Cell... a.&g...

2020-01-05 10:08:20 155

原创 预测人格 项目 python 代码

#mian.pyfrom Enneagram_GUI import *from tkinter import *def center_window(root, width, height): screenwidth = root.winfo_screenwidth() screenheight = root.winfo_screenheight() size ...

2019-12-31 08:01:19 2280 2

原创 python hash运用

#算具体的哈希值import hashlib##网页的哈希值计算# md5=hashlib.md5()# md5.update('http://www.baidu.com'.encode("utf-8"))# print(md5)# print(md5.hexdigest())# 数据去重 哈希过程#文件的哈希值计算for file in ["ddd.txt","dd.tx...

2019-12-27 20:27:49 173

原创 python 布隆过滤

(1)安装相应的模块,不行就到github上找,然后下载下来解压后放到对应的位置执行 pip install .剩下的就是如何引用和修改成自己想要的样子了。布隆过滤器的主要作用是使得查找很快(原理是用的哈希查找),缺点是构建很慢。具体运用: 由于每个文件的哈希值是不一样的;每个病毒的哈希值也是不一样的; 所有可以通过哈希值对比,查找出网...

2019-12-27 20:24:01 201

原创 python 断点调试

(1) 右键,debug(2) step into(3)一次次step into,每次得到都可以看到旁边的x,y,z的此时的值(4)继续step into,会发现执行过程是不断的出栈的过程。总结:程序调用就是不断的进出栈的过程其他操作:stop,start,等;上面调试过程中的灰色部分是一些软件自带的默认的东西,无需理会(具体略)。...

2019-12-27 20:13:48 1008

原创 python 链表的创建和插入

(1)链表的创建#(1) 没有head节点 缺点:需要每次验证是否为空# class node:# def __init__(self,data):# self.data = data# self.next = None# a = node(1)# b = node(2)# v = node# c = node(3)# a.next = v# v.nex...

2019-12-26 14:42:53 1138

原创 python批量翻译各种备注信息

(1)小强版import http.clientimport hashlibimport urllibimport randomimport jsondef etoc(text): appid = '' # 填写你的appid secretKey = '' # 填写你的密钥 myurl = '/api/trans/vip/translate' ...

2019-12-26 14:35:34 202

原创 python 的 yield

(1)简单输出用next、senddef foo(): while True: s = yield 23 print("res",s)g = foo()print(next(g))print(g.send(45))print(next(g))>>23>>res 45>>23>>res None>>2...

2019-12-26 14:25:14 75

原创 python 输出乘法口诀

1.正向输出for i in range(1,10): for j in range(i,10): #print("{}*{}={}".format(i,j,i*j)) print(str(i)+"*"+str(j)+"="+str(i*j)+" ",end="") print()2.逆向输出for i in range(...

2019-04-09 21:31:22 1708

原创 python 列表推导

1.numbers = range(10)size = len(numbers)evens = []i = 0while i < size: if i % 3 == 0: evens.append(i) i += 1 print(evens)以上是痛苦的,在c语言中或许可行,在python中却是不合理的,执行速度会很慢。简化为...

2019-04-08 21:03:07 108

原创 python读写文件操作

1.写文件路径:/Users/bob/st.txt为了避免在不同的系统中运行出错,故使用模块os来创建文件路径;模块中path函数接受文件路径中的文件夹名为参数,并自动构建完整的文件路径。(缺点:在不同的系统中,处理文件时候还是容易出错;只是避免了创建文件路径能正常运行)import osos.path.join( "Users", ...

2019-03-27 14:47:55 127

原创 cookie的设置、获取和删除

1.from flask import Flask,make_responseapp = Flask(__name__)@app.route("/set_cookie")def set_cookie(): resp = make_response("success!") #设置cookie,默认有效期是临时,浏览器关闭就失效 resp.set_cook...

2019-03-22 17:51:37 833

原创 返回json数据的方法

1.最原始的方法(繁琐)2使用jsonify3.jsonify直接传参数

2019-03-22 14:21:33 760

原创 abort函数及自定义异常处理

1.abort函数from flask import Flask,abort,request,Responseapp = Flask(__name__)@app.route("/login",methods=["GET","POST"])def login(): name = request.form.get() pwd = request.form.get(...

2019-03-21 22:03:43 740

原创 flask中路由转换器

1.flask自带的转换器@app.route("/goods/<int:goods_id>")def goods_detail(goods_id): return "goods detail %s" % goods_id @app.route("/user/<int:id>")def hello_itcast(id): return "he...

2019-03-20 19:07:20 488

原创 flask初始化参数和路由

1. app = Flask(__name__)启动模块的"__name__"是写死的,是"__main__";而不是文件名不把模块当启动,当成包被使用,如被导入,则“__name__”是导入的文件名:app = Flask(“__main__”)也是可以的会自动寻找static文件夹下的文件:传一个任意字符串,或者留空,都是不友好的。虽然多数情况程序都没...

2019-03-19 23:36:48 705

原创 windows 下的 virtualenv

1)安装:pip install virtualenvwrapper-win 或者pip install virtualenv cmd下输入:前提是你的python安装路径已经被添加到环境变量中2)常用操作命令:a)创建:virtualenv myvirtual 或 mkvirtualenv myvirtualb) 删除:rmvirtualenv myvir...

2019-03-15 20:51:41 114

flask-微电影项目

1.环境和工具win7、python3.7、sublime Text(a)virtualenv的安装需要使用pip命令:pip installvirtualenv运行完成后,运行virtualenv --version 查看是否成功安装virtualenv -h 命令来查看帮助文档先在PC的某个文件夹里新建一个你的工作文件夹,然后cd到该目录下NOTE:电脑环境变...

2019-03-15 17:42:59 461

原创 http通讯过程

1.不一定是浏览器才能访问服务端。手机的app,程序的爬取数据,python的urllib和urllib2,ajax等都可以访问服务器2.tcp传输是一个请求与响应的过程。3.Django等框架只是为了解决路由分发。框架核心:实现路由和视图(业务逻辑处理)4.process和thread的数字,可以看出是不是多进程和多线程的服务器模型注:看不到的那个词是“回传”...

2019-03-15 16:44:37 662

原创 过程式编程 vs 面向对象编程&函数式编程

1.过程式编程x = 2 y = 4z = 8xyz = x + y + z xyz上述代码每个过程都改变了程序的状态。过程式编程,数据存储在全局变量中,并通过函数处理。示例如下:rock = []country = []def collect_songs(): song = "Enter a song." ask = "Type ...

2019-03-15 16:18:54 3160

原创 leetcode 、两个数的和、三个数的和、python

1.Given nums = [2, 7, 11, 15], target = 9,Because nums[0] + nums[1] = 2 + 7 = 9,return [0, 1].分析:[x,y] ——&gt;x+y=9,复杂度O(n**2);y=9-x...O(1)....loops....O(n),复杂度O(n)代码:class Solution: ...

2019-03-12 16:40:50 311

原创 python 算法 小试牛刀

1.打印从1到100,碰到3倍数用fizz代替,碰到5倍数,用buzz代替,3和5的倍数,FizzBuzz代替def func(): for i in range(1,101): if i % 3 == 0 &amp; i % 5 == 0 print("FizzBuzz") elif i % 3 == 0: ...

2019-03-12 00:50:24 213

原创 target=’_blank’ 安全漏洞

如果你在页面上的超链接a标记上添加了target=”_blank”属性,一个非常简单的钓鱼攻击的漏洞很可能就这样打开了。攻击者只需要在他的页面上放置简单的JavaScript代码,就能轻松的控制你的页面的显示。if (window.opener) { window.opener.location = “https://www.webhek.com“; } 通常我们知道使用 window....

2016-09-21 14:10:33 265

ChromeFG_v2014.08.20.7z

想到外面去的人,就进吧,,虽然旧了点,坑了点,想要更好的,就来找我,,

2015-01-12

空空如也

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

TA关注的人

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