上一页 1 2 3 4 5 6 ··· 9 下一页
摘要: # 定义 class T: a = 123 #类属性 def func(self): #类方法 pass @classmethod def classfunc(cls): pass @staticmethod def staticfunc(): ... 阅读全文
posted @ 2019-01-22 15:49 我是外婆 阅读(283) 评论(0) 推荐(0) 编辑
摘要: import logging from logging import FileHandler, Formatter import os.path as fpath from datetime import datetime logfile = fpath.join(fpath.dirname(fpath.abspath(__file__)),datetime.now().strftime('%Y... 阅读全文
posted @ 2019-01-22 14:29 我是外婆 阅读(559) 评论(0) 推荐(0) 编辑
摘要: import heapq #用heapq 支持自定义对象 #heapq可以用默认list类型来创建堆结构, #用[]来创建堆结构不建议给初始值,如果非得给的话建议先调用heapq.heapify进行转化 import random a = [] for i in range(10): heapq.heappush(a, random.randint(1, 10)) ... 阅读全文
posted @ 2019-01-21 16:41 我是外婆 阅读(818) 评论(0) 推荐(0) 编辑
摘要: ##python 中特殊方法简写方式 class Test: __call__ = lambda *args: args[1] * 2 #这里需要注意lambda的参数 会默认将实例self 加进去 __str__ = lambda self: 'that`s useful...%s' % self.__class__.__name__ t = Test() prin... 阅读全文
posted @ 2019-01-20 01:36 我是外婆 阅读(998) 评论(0) 推荐(0) 编辑
摘要: import sys default_path = r'C:\Users\lon\Desktop' #自定义路径 sys.path.append(default_path) #将自定义路径加到sys模块path路径中 print(sys.path) from test1 import Demo d = Demo() print(d.Hi()) 阅读全文
posted @ 2019-01-19 15:46 我是外婆 阅读(316) 评论(0) 推荐(0) 编辑
摘要: class Program { public static void Main(string[] args) { string[] urls = new string[]{ "http://wwww.baidu.coms", "http://w... 阅读全文
posted @ 2019-01-02 11:31 我是外婆 阅读(440) 评论(0) 推荐(0) 编辑
摘要: 1 class Program 2 { 3 static BlockingCollection cols = new BlockingCollection(2); //设置阻塞队列最大的容量; 4 public static void Main(string[] args) 5 { 6 7 ... 阅读全文
posted @ 2018-12-29 11:22 我是外婆 阅读(1467) 评论(0) 推荐(0) 编辑
摘要: namespace console_class_继承 { class Program { public static void Main(string[] args) { Dog d = new Dog(); d.run(); ... 阅读全文
posted @ 2018-12-28 09:52 我是外婆 阅读(421) 评论(0) 推荐(0) 编辑
摘要: using System; using System.Reflection; namespace console_attribute { class Program { public static void Main(string[] args) { Type t = typeof(Books); ... 阅读全文
posted @ 2018-12-25 10:55 我是外婆 阅读(132) 评论(0) 推荐(0) 编辑
摘要: class Program { static void Main(string[] args) { //通过使用$符号初始化一个字符串,可以在字符串中使用占位符来引用变量 int a = 123; Console.WriteLine($"this value... 阅读全文
posted @ 2018-12-11 15:45 我是外婆 阅读(3139) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 9 下一页