2017-08-03 24 views

回答

5

最簡單的方法,我發現:

package main 

import "fmt" 

func main() { 
    bs := []byte{255, 253} 
    for _, n := range(bs) { 
     fmt.Printf("%b", n) // prints 1111111111111101 
    } 
} 

遊樂場與此代碼:https://play.golang.org/p/jZ8BVqOyLP

+0

還有'strconv.FormatUint'如果你想要的字符串,但同樣的想法。 – JimB

+0

@JimB你有一個操作系統,用'strconv.FormatUint'來打印二進制文件嗎? – Pylinux

+0

https://play.golang.org/p/uNhVG9v3YK – JimB

相關問題