当前位置:网站首页>Golang Basics - string and int, Int64 inter conversion
Golang Basics - string and int, Int64 inter conversion
2022-06-30 12:52:00 【The hunter is eating meat】
Please look at the code.
package main
import (
"fmt"
"reflect"
"strconv"
)
func main() {
var testStr string = "123456"
// character string turn int
intNum, _ := strconv.Atoi(testStr)
fmt.Println("intNum =", intNum, ", intNum The type is ", reflect.TypeOf(intNum))
// character string turn int64
int64Num, _ := strconv.ParseInt(testStr, 10, 64)
fmt.Println("int64Num=", int64Num, ", int64Num The type is ", reflect.TypeOf(int64Num))
// ===================================================
// int turn character string
var intNum2 int = 123456
var str1 string = strconv.Itoa(intNum2)
fmt.Println("str1 =", str1, ", str1 The type is ", reflect.TypeOf(str1))
// int64 turn character string
var int64Num2 int64 = 123456
var str2 string = strconv.FormatInt(int64Num2, 10)
fmt.Println("str2 =", str2, ", str2 The type is ", reflect.TypeOf(str2))
}
Running results :
intNum = 123456 , intNum The type is int
int64Num= 123456 , int64Num The type is int64
str1 = 123456 , str1 The type is string
str2 = 123456 , str2 The type is string
边栏推荐
- [MySQL] MySQL installation and configuration
- 【一天学awk】基础中的基础
- Sublist3r error reporting solution
- Android development interview real question advanced version (with answer analysis)
- [QNX Hypervisor 2.2用户手册]6.2.3 Guest与外部之间通信
- 【OpenGL】OpenGL Examples
- Unity脚本的基础语法(5)-向量
- Motor control Clarke( α/β) Derivation of equal amplitude transformation
- Flink SQL console, group not recognized_ Concat function?
- Definition of variables and assignment of variables in MySQL
猜你喜欢

黑马笔记---集合(Collection的常用方法与遍历方式)

排查问题的方法论(适用于任何多方合作中产生的问题排查)

微信小程序报错:TypeError: Cannot read property ‘setData‘ of undefined

FlinkSQL自定义UDAF使用的三种方式

Flinksql customizes udatf to implement topn
![[learn awk in one day] operator](/img/52/fd476d95202f3a956fd59437c2d960.png)
[learn awk in one day] operator

资源变现小程序开通流量主教程

Derivation of Park transformation formula for motor control

Idea has a new artifact, a set of code to adapt to multiple terminals!

Analysis of smart jiangcai login in Jiangxi University of Finance and Economics
随机推荐
QT implementation dynamic navigation bar
MySQL判断执行条件为NULL时,返回0,出错问题解决 Incorrect parameter count in the call to native function ‘ISNULL‘,
Unity脚本的基础语法(4)-访问其他游戏对象
Scratch drawing square electronic society graphical programming scratch grade examination level 2 true questions and answers analysis June 2022
Android development interview real question advanced version (with answer analysis)
JS 二维数组变一维数组的方法
Tronapi- wavefield interface - source code without encryption - can be opened in two places - interface document attached - encapsulation based on thinkphp5 - detailed guidance of the author - 21:59:3
ECDSA signature verification in crypt
LeetCode_栈_中等_227.基本计算器 II(不含括号)
Substrate 源码追新导读: 修复BEEFY的gossip引擎内存泄漏问题, 智能合约删除队列优化
电机控制park变换公式推导
How to solve cross domain problems
Qt读写Excel--QXlsx工作表显示/隐藏状态设置4
jmeter 学习笔记
Substrate 源码追新导读: 质押额度大幅度削减, RocksDB可以完全被Disable
Tronapi wave field interface PHP version - interface document attached - package based on thinkphp5 - source code without encryption - can be opened in two - detailed guidance of the author - 11:49:56
【一天学awk】运算符
7 lightweight and easy-to-use tools to relieve pressure and improve efficiency for developers, and help enterprises' agile cloud launch | wonderful review of techo day
机器学习笔记 - 自相关和偏自相关简介
【OpenGL】OpenGL Examples