【golang踩“坑”记】 string(fid) 与 strconv.Itoa(fid)
发布时间:2020-12-16 18:22:25 所属栏目:大数据 来源:网络整理
导读:踩坑记 string(fid) 与 strconv.Itoa(fid) 遇到坑 在用golang做laravel进程管理的时候,发现一个“坑”: strconv.Itoa(fid) 才能达到想要的数字字符 string(fid) 并不能!!(因为该转换会将数字直接转换为该数字对应的内码) fidstr := strconv.Itoa(fid)
踩坑记 string(fid) 与 strconv.Itoa(fid)遇到坑在用golang做laravel进程管理的时候,发现一个“坑”: strconv.Itoa(fid) 才能达到想要的数字字符 fidstr := strconv.Itoa(fid) fidstr := string(fid) fmt.Printf("exec: %s %s %s %sn",php,artisan,option,fidstr) cmd := exec.Command(br.php,br.artisan,br.option,fidstr) 当且仅当 比如: 测试两种方式的 ASCII 值看测试代码 func Test_IntToString(t *testing.T) { fmt.Printf("string(1) = %vn",[]byte(string(1))) fmt.Printf("strconv.Itoa(1) = %vn",[]byte(strconv.Itoa(1))) } 我们得到运行如下结果: string(1) = [1] strconv.Itoa(1) = [49] 结论已经很明显, (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |