随笔分类 -  有疑问

摘要:问题:1.)上面的__init__函数中,加*句我不写,为啥不可以?不理解里面怎么传递。。。初始化的时候不是先在内部调用了__init__,生成了L了吗? 下面函数不能用这里的L,甚至是 a,b这些变量? 2.)如果要让 init 下的变量传到别的函数,是不是一定要用self.var这种形式? 我自 阅读全文
posted @ 2022-10-19 08:16 ty1539 阅读(19) 评论(0) 推荐(0) 编辑
摘要:# # Create your tests here. # 延迟绑定 # Python闭包函数所引用的外部自由变量是延迟绑定的。 def multipliers(): return [lambda x: i * x for i in range(4)] print ([m(2) for m in m 阅读全文
posted @ 2022-06-30 23:25 ty1539 编辑
摘要:## go etcd 用脚本多次设置,无法替换, 设置后无法用 etcdctl.exe get 方法获取,有疑问 package main import ( "context" "fmt" etcd_client "go.etcd.io/etcd/clientv3" // 对于第三方开源组件, 取别 阅读全文
posted @ 2022-05-14 21:58 ty1539 阅读(117) 评论(0) 推荐(0) 编辑
摘要:class FloatRange: def __init__(self, start, end, step=0.1): self.start = start self.end = end self.step = step def __iter__(self): t = self.start whil 阅读全文
posted @ 2022-05-04 11:37 ty1539 阅读(69) 评论(0) 推荐(0) 编辑
摘要:https://www.cnblogs.com/welhzh/p/8981096.html 1, math/big package main import ( "fmt" "math/big" "time" ) const LIM = 10000 //求第10000位的费布拉切数 var fibs 阅读全文
posted @ 2022-04-24 23:52 ty1539 阅读(117) 评论(0) 推荐(0) 编辑
摘要:https://blog.csdn.net/qq_33801641/article/details/119793104 阅读全文
posted @ 2022-04-12 11:38 ty1539 阅读(18) 评论(0) 推荐(0) 编辑
摘要:https://blog.csdn.net/flyfreelyit/article/details/80281467 https://www.cnblogs.com/liyutian/p/10287655.html 阅读全文
posted @ 2022-03-16 19:11 ty1539 阅读(54) 评论(0) 推荐(0) 编辑
摘要:package main import ( "fmt" "math/rand" ) type Job struct { Number int Id int } type Result struct { job *Job sum int } func calc(job *Job, result cha 阅读全文
posted @ 2022-03-10 23:19 ty1539 阅读(164) 评论(0) 推荐(0) 编辑
摘要:package main import ( "fmt" "runtime" "time" ) var i int func calc(i1 int) { for ;i < 10; i++ { // 死循环,不会自己结束的 //i ++ fmt.Printf("全局i:%d >>> 局部i1:%d g 阅读全文
posted @ 2022-03-10 23:13 ty1539 阅读(110) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 package main import "fmt" type Animal interface{ Talk() Eat() Name() string } type Dog struct{} func (d Dog) Talk(){ fmt.Println("汪汪汪") } func 阅读全文
posted @ 2022-03-07 23:09 ty1539 阅读(22) 评论(0) 推荐(0) 编辑
摘要:注意:testdefer3() defer 与testdefer4() defer匿名函数 的区别,这是易错点 package main import ( "fmt" ) // defer在函数返回的时候执行,多用于资源释放(打开文件,打开数据库连接,函数返回之后,关闭连接) func testde 阅读全文
posted @ 2022-03-06 19:24 ty1539 阅读(96) 评论(0) 推荐(0) 编辑
摘要:注意: go的defer和defer匿名函数,中输出的i值不一样 点击查看代码 package main import "fmt" func testFunc3(){ var i int =0 fmt.Printf("testFunc3 i=%d\n",i) defer fmt.Printf("de 阅读全文
posted @ 2022-03-06 19:00 ty1539 阅读(22) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 package main import ( "fmt" "strings" "time" ) func Adder() func(int) int { var x int = 3 return func(d int) int { x += d return x } } func tes 阅读全文
posted @ 2022-03-06 18:15 ty1539 阅读(25) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 package main import ( "fmt" "math/big" ) func genFibLst(n int) (a []string) { n1 := big.NewInt(1) n2 := big.NewInt(1) fmt.Printf("n1=%s, n2=%s, 阅读全文
posted @ 2022-02-27 14:01 ty1539 阅读(127) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示