随笔分类 -  python

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 48 下一页
摘要:__enter__():在使用with语句时调用,会话管理器在代码块开始前调用,返回值与as后的参数绑定 __exit__():会话管理器在代码块执行完成好后调用,在with语句完成时,对象销毁之前调用 阅读全文
posted @ 2019-07-25 12:13 anobscureretreat 阅读(160) 评论(0) 推荐(0)
摘要:+ 每次进行相加都会开辟新的空间,回收旧的空间join 一次性开辟好空间,一次性添加进去,一次性回收 阅读全文
posted @ 2019-07-25 09:52 anobscureretreat 阅读(273) 评论(0) 推荐(0)
摘要:code 阅读全文
posted @ 2019-07-20 08:57 anobscureretreat 阅读(599) 评论(0) 推荐(0)
摘要:code 输出 阅读全文
posted @ 2019-07-20 08:55 anobscureretreat 阅读(297) 评论(0) 推荐(0)
摘要:>>> str="hello world">>> x=bytearray(str)>>> xbytearray(b'hello world')>>> x.decode()u'hello world' >>>bytearray()bytearray(b'')>>> bytearray([1,2,3]) 阅读全文
posted @ 2019-07-20 08:54 anobscureretreat 阅读(539) 评论(0) 推荐(0)
摘要:ipv4 IPv6的正则匹配表达式 参考: https://www.cnblogs.com/brogong/p/7929298.html 阅读全文
posted @ 2019-07-18 23:34 anobscureretreat 阅读(2358) 评论(0) 推荐(0)
摘要:def str_to_hex(s): return ' '.join([hex(ord(c)).replace('0x', '') for c in s]) def hex_to_str(s): return ''.join([chr(i) for i in [int(b, 16) for b in s.split(' ')]]) def str_to_bin(s): ... 阅读全文
posted @ 2019-07-18 22:07 anobscureretreat 阅读(13890) 评论(0) 推荐(1)
摘要:这个错误很明显 ,是因为你关闭了套接字对象后,又再次去调用了套接字对象,此时套接字链接已经被关闭,你不能再去调用,所以才会出现这种错误,复查一下自己的代码,很快就可以解决。 参考: https://blog.csdn.net/weixin_40612082/article/details/80032 阅读全文
posted @ 2019-07-18 22:05 anobscureretreat 阅读(6746) 评论(0) 推荐(0)
摘要:经过检查发现,是由于客户端请求的链接,在一次循环之后,产生的套接字关闭,没有新的客户端套接字进行请求连接,所以产生broken pipe错误 阅读全文
posted @ 2019-07-18 22:03 anobscureretreat 阅读(2269) 评论(0) 推荐(0)
摘要:常用的地址家族AF_UNIX:基于文件,实现同一主机不同进程之间的通信AF_INET:基于网络,适用于IPv4AF_INET6:基于网络,使用于IPv6 常见的连接类型SOCK_STREAM:即TCP/IP。面向连接的套接字,通信之前必须建立可靠的连接。面向连接的套接字提供序列化的、可靠的和不重复的 阅读全文
posted @ 2019-07-18 22:00 anobscureretreat 阅读(348) 评论(0) 推荐(0)
摘要:import sys, select, tty, termios old_attr = termios.tcgetattr(sys.stdin) tty.setcbreak(sys.stdin.fileno()) print('Please input keys, press Ctrl + C to quit') while(1): if select.select([s... 阅读全文
posted @ 2019-07-18 21:58 anobscureretreat 阅读(5589) 评论(0) 推荐(0)
摘要:Python2.x中的input()函数input()函数让我们明确我们输入的是数字格式还是字符格式,就是我们自己要知道我们想要的是什么,数字格式直接输入,字符格式必须加上单引号或者双引号,以确定我们输入的是字符串。 Python2.x中的raw_input()函数:>>> a = raw_inpu 阅读全文
posted @ 2019-07-18 21:58 anobscureretreat 阅读(855) 评论(0) 推荐(0)
摘要:json->string str = json.dumps(jsonobj) bytes->string str = str(bytes,‘utf-8’) string->json json = json.loads(str) 参考: https://www.cnblogs.com/xiandeda 阅读全文
posted @ 2019-07-18 01:02 anobscureretreat 阅读(1165) 评论(0) 推荐(0)
摘要:参考: https://www.cnblogs.com/niuu/p/10106897.html https://www.cnblogs.com/Lin-Yi/p/7640147.html 阅读全文
posted @ 2019-07-18 01:00 anobscureretreat 阅读(9509) 评论(0) 推荐(1)
摘要:demo1 输出 demo2 使用send传递一个值到yield的那行,于是res=7 输出 demo3 使用生成器的场景,你有一个10000个元素的列表要处理,如果用List的话,会占用更大的空间,比如说取0,1,2,3,4,5,6............10000 这个时候range(10000 阅读全文
posted @ 2019-07-18 00:28 anobscureretreat 阅读(232) 评论(0) 推荐(0)
摘要:l1 = ['b','c','d','c','a','a'] l2 = list(set(l1)) print(l2) 阅读全文
posted @ 2019-07-16 01:12 anobscureretreat 阅读(332) 评论(0) 推荐(0)
摘要:list1 = [1,2,3] list2 = [3,4,5] set1 = set(list1) set2 = set(list2) print(set1 & set2) print(set1 ^ set2) 阅读全文
posted @ 2019-07-16 01:11 anobscureretreat 阅读(538) 评论(0) 推荐(0)
摘要:print([x*11 for x in range(10)]) 阅读全文
posted @ 2019-07-16 01:10 anobscureretreat 阅读(665) 评论(0) 推荐(0)
摘要:放慢抓取熟速度,减小对目标网站造成的压力,但是这样会减少单位时间内的数据抓取量 使用代理IP(免费的可能不稳定,收费的可能不划算) 阅读全文
posted @ 2019-07-16 01:08 anobscureretreat 阅读(338) 评论(0) 推荐(0)
摘要:无头浏览器即headless browser,是一种没有界面的浏览器。既然是浏览器那么浏览器该有的东西它都应该有,只是看不到界面而已。 Python中selenium模块中的PhantomJS即为无界面浏览器(无头浏览器):是基于QtWebkit的无头浏览器。 Python中selenium模块中的 阅读全文
posted @ 2019-07-16 01:04 anobscureretreat 阅读(1170) 评论(0) 推荐(0)

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 48 下一页