随笔分类 -  Python

dom 操作
摘要:DOM(Document Object Model 文档对象模型) 一个web页面的展示,是由html标签组合成的一个页面,dom对象实际就是将html标签转换成了一个文档对象。可以通过dom对象中js提供的方法,找到html的各个标签。通过找到标签就可以操作标签使页面动起来,让页面动起来。 获取标 阅读全文

posted @ 2018-07-03 11:37 公子兔 阅读(136) 评论(0) 推荐(0)

css选择器 http://www.imdsx.cn/index.php/2017/07/27/html1/
摘要:CSS选择器 1、id选择器 2、class选择器 3、标签选择器 4、层级选择器(空格) 5、组合选择器(逗号) 6、属性选择器(中括号) <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</ti 阅读全文

posted @ 2018-07-03 11:30 公子兔 阅读(326) 评论(0) 推荐(0)

css样式
摘要:<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <style> .c1{ height: 100px; width: 100px; border: 2px aquamarine sol 阅读全文

posted @ 2018-06-20 14:14 公子兔 阅读(112) 评论(0) 推荐(0)

html
摘要:<!DOCTYPE html><!-- 规定标准的HTML--><!--一个页面只有一个HTML标签--><html lang="en"><head> <!--头部当中大部分标签是不可见的--> <!--自闭和标签--> <meta charset="UTF-8"> <!--每隔一秒钟刷新一次页面- 阅读全文

posted @ 2018-06-20 14:13 公子兔 阅读(122) 评论(0) 推荐(0)

yaml
摘要:YAML 是专门用来写配置文件的语言,非常简洁和强大,远比 JSON 格式方便。 YAML在python语言中有PyYAML安装包。 pip install pyyaml它的基本语法规则如下: 1、大小写敏感 2、使用缩进表示层级关系 3、缩进时不允许使用Tab键,只允许使用空格。 4、缩进的空格数目不重要,只要相同层级的元素左侧对齐即可 5、# 表示注释,从这... 阅读全文

posted @ 2018-06-06 10:06 公子兔 阅读(230) 评论(0) 推荐(0)

测试登录:unittest,BeautifulReport
摘要:import unittest,requestsimport ddtfrom BeautifulReport import BeautifulReport as bffrom urllib import parse@ddt.ddtclass Login(unittest.TestCase): bas 阅读全文

posted @ 2018-06-05 17:57 公子兔 阅读(306) 评论(0) 推荐(0)

单元测试unittest
摘要:class TestCalc(unittest.TestCase): def setUp(self): print('setup是啥时候运行的') #每个用例运行之前运行的 def tearDown(self): print('teardown是啥时候运行') #每个用例运行之后运行的 @class 阅读全文

posted @ 2018-06-05 17:48 公子兔 阅读(139) 评论(0) 推荐(0)

多线程、进程
摘要:import threading,timedef run(): time.sleep(3) #干活需要3s print('哈哈哈')# for i in range(5): #串行# run()# for i in range(5):# t = threading.Thread(target=run 阅读全文

posted @ 2018-05-30 17:01 公子兔 阅读(141) 评论(0) 推荐(0)

线程锁
摘要:import threading,timenum = 1lock = threading.Lock() #申请一把锁def run(): time.sleep(1) global num lock.acquire() #加锁 num+=1 lock.release() #解锁ts = []for i 阅读全文

posted @ 2018-05-30 17:01 公子兔 阅读(91) 评论(0) 推荐(0)

重写父类方法
摘要:# coding=utf-8class Zll(): # def smile(self): # print('哈哈哈') # return 'aa' passclass Dcg(): def smile(self): print('啊啊啊啊啊')class Lw(): def smile(self) 阅读全文

posted @ 2018-05-30 16:59 公子兔 阅读(203) 评论(0) 推荐(0)

main
摘要:if __name__ == '__main__':#判断这个Python文件是导入的,还是直接在运行这个Python文件 这句话一般是做调试的时候用的。 如果是直接运行这个Python文件的时候,这个一点用都没有 阅读全文

posted @ 2018-05-20 14:51 公子兔 阅读(182) 评论(0) 推荐(0)

class私有
摘要:import redisclass My(object): def __init__(self): self.__host='118.24.3.40'#self变量前面加__,出了类就不能用了 self.__port=6379 self.__password='HK139bc&*' self.r=r 阅读全文

posted @ 2018-05-20 14:50 公子兔 阅读(156) 评论(0) 推荐(0)

根据签名规则,加密URL
摘要:from urllib import parseurl='http://www.baidu.com?query=python基础教程'url_str=parse.quote_plus(url)#URL编码baidu_url='http%3A%2F%2Fwww.baidu.com%3Fquery%3D 阅读全文

posted @ 2018-05-20 14:48 公子兔 阅读(207) 评论(0) 推荐(0)

class连接数据库
摘要:import pymysqlclass MyDb(object): def __init__(self,host,user,passwd,db,port=3306,charset='utf8'): try: self.coon=pymysql.connect( host=host,user=user 阅读全文

posted @ 2018-05-20 14:46 公子兔 阅读(622) 评论(0) 推荐(0)

类方法@classmethod、属性方法@property、静态方法 @staticmethod
摘要:class Baby(): # def __init__(self,name):#构造函数不是必须得 # print('self的内存地址',id(self)) # self.name=name # #self代表的就是实例化之后的对象 # self.money=5000 # self.sex='女 阅读全文

posted @ 2018-05-20 14:44 公子兔 阅读(257) 评论(0) 推荐(0)

class继承
摘要:class Lz(object): def __init__(self): self.money=1000000000000 self.house='大别野' def sing(self): print('唱歌') def dance(self): print('跳广场舞') def lm(self 阅读全文

posted @ 2018-05-20 14:41 公子兔 阅读(185) 评论(0) 推荐(0)

面向对象变成class
摘要:类 一个种类,一个模型。汽车模型对象 指具体的东西,模型造出来的东西叫做对象实例 实例和对象是一样的。实例化 实例化就是造东西的这个过程属性 属性就是变量方法 类里面的函数继承封装多态self 代表的是本类对象因为函数里面的变量都是局部变量,出了函数就不能用了。用self给对象绑定了之后,就可以se 阅读全文

posted @ 2018-05-19 17:50 公子兔 阅读(175) 评论(0) 推荐(0)

网络编程
摘要:from urllib import request,parse# url='http://www.nnzhp.cn'# req=request.urlopen(url) #打开URL,发get请求# content=req.read().decode()# fw=open('baidu.html' 阅读全文

posted @ 2018-05-17 21:02 公子兔 阅读(106) 评论(0) 推荐(0)

requests模块
摘要:import requests,random#发get请求# url='http://api.nnzhp.cn/api/user/stu_info'# data={'stu_name':'小黑'}#请求数据# req=requests.get(url,params=data)#发get请求# pri 阅读全文

posted @ 2018-05-15 16:23 公子兔 阅读(125) 评论(0) 推荐(0)

try异常处理
摘要:#异常处理 兼容性更好 更健壮 first = input('请输入除数:')second = input('请输入被除数:')try: first = int(first) second = int(second) res = first/second li = [1,2,3,4]# except 阅读全文

posted @ 2018-05-15 16:23 公子兔 阅读(145) 评论(0) 推荐(0)

导航