If you can how to swap?
Like a string (80) can get P
But the letter how to convert the ASCII code?
CodePudding user response:
S:=string (80)
//string can only first array, and then according to the length of the array in each element
Arr=(byte []) (s)
Num:=arr [0]
CodePudding user response:
S:='P'
B:=(byte) (s)
FMT. Println (b)
CodePudding user response:
Please use the for range string tryCodePudding user response:
You can use a rune types, the code is as follows:
Var a rune='P'
FMT. Println (" a: ", a)
FMT. Println (" a: ", string (a))
FMT. Println (" a: ", string (80))
Results:
A: 80
A: P
A: P
CodePudding user response:
Single letter can use strconv. AtoiString can use byte [] (STR)
CodePudding user response:
P:=FMT. Sprintf (" % c ", 80)