上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页
摘要: 1 a,b = 0, 1 2 while b<100: 3 print (b), 4 a, b = b, a+b 阅读全文
posted @ 2020-12-31 17:42 QC_der 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Python引用了一个内存池(memory pool)机制,即Pymalloc机制(malloc:n.分配内存),用于管理对小块内存的申请和释放内存池(memory pool)的概念: 当 创建大量消耗小内存的对象时,频繁调用new/malloc会导致大量的内存碎片,致使效率降低。内存池的概念就是预 阅读全文
posted @ 2020-12-31 17:39 QC_der 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 1 >>> l = tuple(iplist) 2 >>> print l 3 ('217.169.209.2:6666', '192.227.139.106:7808', '110.4.12.170:83', '69.197.132.80:7808', '205.164.41.101:3128', 阅读全文
posted @ 2020-12-31 17:21 QC_der 阅读(733) 评论(0) 推荐(0) 编辑
摘要: 1 函数 描述 2 int(x [,base ]) 将x转换为一个整数 3 long(x [,base ]) 将x转换为一个长整数 4 float(x ) 将x转换到一个浮点数 5 complex(real [,imag ]) 创建一个复数 6 str(x ) 将对象 x 转换为字符串 7 repr 阅读全文
posted @ 2020-12-31 17:19 QC_der 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 与C表达式 bool ? a : b类似,但是bool and a or b,当 a 为假时,不会象C表达式 bool ? a : b 一样工作应该将 and-or 技巧封装成一个函数: def choose(bool, a, b): return (bool and [a] or [b])[0] 阅读全文
posted @ 2020-12-31 17:17 QC_der 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 1 #使用装饰器(decorator), 2 #这是一种更pythonic,更elegant的方法, 3 #单例类本身根本不知道自己是单例的,因为他本身(自己的代码)并不是单例的 4 def singleton(cls, *args, **kw): 5 instances = {} 6 def _s 阅读全文
posted @ 2020-12-31 17:15 QC_der 阅读(59) 评论(0) 推荐(0) 编辑
摘要: 1 #使用__metaclass__(元类)的高级python用法 2 class Singleton2(type): 3 def __init__(cls, name, bases, dict): 4 super(Singleton2, cls).__init__(name, bases, dic 阅读全文
posted @ 2020-12-31 17:12 QC_der 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 1 >>> l = [1,1,2,3,4,5,4] 2 >>> list(set(l)) 3 [1, 2, 3, 4, 5] 4 或者 5 d = {} 6 for x in mylist: 7 d[x] = 1 8 mylist = list(d.keys()) 阅读全文
posted @ 2020-12-31 17:09 QC_der 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 1 #! /usr/bin/env python 2 #coding=utf-8 3 import sys 4 import time 5 import poplib 6 import smtplib 7 #邮件发送函数 8 def send_mail(): 9 try: 10 handle = s 阅读全文
posted @ 2020-12-31 16:45 QC_der 阅读(107) 评论(0) 推荐(0) 编辑
摘要: python 编写server的步骤:1. 第一步是创建socket对象。调用socket构造函数。如: socket = socket.socket( family, type ) family参数代表地址家族,可为AF_INET或AF_UNIX。AF_INET家族包括Internet地址,AF_ 阅读全文
posted @ 2020-12-31 16:40 QC_der 阅读(214) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页
返回顶端