func main() {
//转换为字符串后追加到字节数组
slice := make([]byte, 1024)
slice = strconv.AppendBool(slice, true)
//第二个数为要追加的数,第三个数为指定10进制方式追加
slice = strconv.AppendInt(slice, 1234, 10)
slice = strconv.AppendQuote(slice, "abcgohello")
fmt.Println("slice = ", string(slice))
//其它类型转换为字符串
var str string
str = strconv.FormatBool(false)
fmt.Println("str = ", str)
//'f'指打印格式,以小数形式,-1指小数点位数,64以float64处理
str = strconv.FormatFloat(3.14, 'f', -1, 64)
fmt.Println("str = ", str)
//整型转字符型
str = strconv.Itoa(6666)
fmt.Println("str = ", str)
//字符串转其它类型
flag, err := strconv.ParseBool("true")
if err != nil {
fmt.Println("err = ", err)
}
fmt.Println("flag = ", flag)
//字符串转换为整型
a, _ := strconv.Atoi("56479")
fmt.Println("a = ", a)
}
- 输出
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- go基础库之替换部分字符串
- SQL Server中利用正则表达式替换字符串的方法
- 使用sed和awk查找和替换字符串处理Makefile文件(三)
- CSS 基础:块级元素、行内元素、替换元素、非替换元素
- Vim 中怎么将目标字符替换成新行以及如何替换换行符
- PowerShell正则替换实战
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Complexity and Approximation
G. Ausiello、P. Crescenzi、V. Kann、Marchetti-sp、Giorgio Gambosi、Alberto M. Spaccamela / Springer / 2003-02 / USD 74.95
This book is an up-to-date documentation of the state of the art in combinatorial optimization, presenting approximate solutions of virtually all relevant classes of NP-hard optimization problems. The......一起来看看 《Complexity and Approximation》 这本书的介绍吧!