12 2024 档案

摘要:普通打印json数据 package main import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" ) func main() { // API 地址 url := "https://jsonplaceholder.typicode 阅读全文
posted @ 2024-12-30 14:22 __username 阅读(271) 评论(0) 推荐(0)
摘要:注意事项 阅读全文
posted @ 2024-12-24 09:21 __username 阅读(282) 评论(0) 推荐(0)
摘要:环境 golang gcc 我gcc用的链接(sjlj):https://share.weiyun.com/7PNY3ab1 自行添加到环境变量中 编程一个go代码 如要调用dll 初始化操作 init函数即可 package main import "C" // 一定要export 函数 //ex 阅读全文
posted @ 2024-12-23 22:57 __username 阅读(409) 评论(0) 推荐(0)
摘要:![](https://img2024.cnblogs.com/blog/3005444/202412/3005444-20241221124854284-642943398.png) 阅读全文
posted @ 2024-12-21 12:50 __username 阅读(259) 评论(0) 推荐(0)
摘要:Go语言提供了多种格式化输出的功能,主要通过标准库中的 fmt 包实现。下列一些基本的格式化输出方法: 打印函数: fmt.Print(): 基本的打印功能,输出后不自动添加换行。 fmt.Println(): 输出后自动添加换行。 fmt.Printf(): 支持格式化字符串。 格式化占位符: % 阅读全文
posted @ 2024-12-16 00:06 __username 阅读(311) 评论(0) 推荐(0)
摘要:// 设置代理地址 proxyURL, err := url.Parse("http://114.233.71.74:40009") if err != nil { fmt.Println("代理 URL 解析失败:", err) return } // 自定义 Transport 使用代理 tra 阅读全文
posted @ 2024-12-11 21:48 __username 阅读(32) 评论(0) 推荐(0)
摘要:var Logger *log.Logger // 初始化日志器 func InitLogger(logFilePath string) { // 打开日志文件 file, err := os.OpenFile(logFilePath, os.O_APPEND|os.O_CREATE|os.O_WR 阅读全文
posted @ 2024-12-11 19:14 __username 阅读(26) 评论(0) 推荐(0)
摘要:安装 Go 使用官方包管理器安装(版本可能不是最新): 查看版本: apt list golang // 是1.13版本(太老了),直接从官网下载 sudo apt update sudo apt install -y golang 从官方网站下载安装(推荐,获取最新版本): wget https: 阅读全文
posted @ 2024-12-10 19:14 __username 阅读(91) 评论(0) 推荐(0)
摘要:在 Go 语言中,当爬虫返回 JSON 数据时,可以通过 encoding/json 包解析 JSON 数据并提取其中的值。以下是两种常见方法来解析 JSON 数据并获取特定字段(如 code)。 示例 JSON 数据 假设你爬取到的 JSON 数据如下: { "code": 200, "messa 阅读全文
posted @ 2024-12-10 15:21 __username 阅读(88) 评论(0) 推荐(0)
摘要:package main import ( "fmt" "io" "log" "net/http" "os" "regexp" "strings" "sync" ) func gomoun(c chan int) { for i := 0; i < 10000; i++ { c <- i } clo 阅读全文
posted @ 2024-12-09 20:53 __username 阅读(15) 评论(0) 推荐(0)
摘要:func findStr() { testStr := "There are 123 apples and 456 oranges." // 查找所有匹配的子字符串 pattern := `\d+` // 匹配一个或多个数字 re := regexp.MustCompile(pattern) // 阅读全文
posted @ 2024-12-09 16:16 __username 阅读(16) 评论(0) 推荐(0)
摘要:resp, err := client.Do(req) if err != nil { results <- fmt.Sprintf("Request error: %v", err) return } defer resp.Body.Close() bodyText, err := io.Read 阅读全文
posted @ 2024-12-09 15:53 __username 阅读(21) 评论(0) 推荐(0)
摘要:Python 3.10 引入了一个重要的新特性:结构化模式匹配(Structural Pattern Matching),主要通过 match 语句实现。它类似于其他编程语言(如 C、JavaScript、Go)中的 switch-case 语句,但功能更强大,支持更复杂的模式匹配。 基本语法: m 阅读全文
posted @ 2024-12-04 01:08 __username 阅读(216) 评论(0) 推荐(0)