K
K
kazhuravlev2014-10-08 08:22:58
Python
kazhuravlev, 2014-10-08 08:22:58

What is the Python equivalent of the chr() function in Golang?

How to write code similar to the following Python code in Go?

from struct import pack

p = 7777
result = pack('!H', p)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
Tyranron, 2014-10-08
@Tyranron

This should help:
stackoverflow.com/questions/20922598/golang-packin...

S
Sergey, 2014-10-08
Protko @Fesor

type  result struct {
    p uint16
}

no packs are needed, since we are already dealing with binary structures.

A
Andrey K, 2015-03-17
@mututunus

import (
  "bytes"
  "encoding/binary"
)

func main() {
  buffer := new(bytes.Buffer)

  var p int32
  p = 7777
  binary.Write(buffer, binary.BigEndian, p)

  result := buffer.Bytes()
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question