![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
GoLang
GO语言个人笔记
cTens
这个作者很懒,什么都没留下…
展开
-
Golang结构体排序
Golang对结构体字段排序的案例本案例通过 sort 方法,对产品的 price 字段进行排序,仅供参考...package mainimport ( "fmt" "sort")type Product struct { Name string Price float64 Date string}type DataSlice struct { Data []Product By func(q, p *Product) bool}// 重写 Len() 方法原创 2022-03-04 16:57:13 · 635 阅读 · 0 评论 -
Golang / Python 邮件发送
Python:邮件发送代码:import timeimport smtplibfrom email.mime.text import MIMETextfrom email.mime.multipart import MIMEMultipartfrom email.mime.application import MIMEApplicationdef create_email(f_name, e_send, e_recipient): # 创建邮箱内容格式 message =原创 2021-11-12 17:40:28 · 726 阅读 · 0 评论 -
golang中GDK和UTF8编码转换
官方提供的GDK转换方式:import ( "bytes" "fmt" "golang.org/x/text/encoding/simplifiedchinese" "golang.org/x/text/transform" "io/ioutil")func main() { content := "编码转换内容内容" gdkData, _ := ioutil.ReadAll(transform.NewReader(bytes.NewReader([]byte(content)), s原创 2021-03-05 15:35:00 · 1117 阅读 · 0 评论