Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试将整数转换为 ruby 中的十六进制,但我遇到了麻烦。我需要它的格式为 \x00 但如果您不手动设置它似乎是不可能的?
count = 5 hex = "\x0#{count}" puts hex.inspect # "\x005" but i need it to be "\x05"
谢谢!
["\x00".unpack("C").first + count].pack("C")
#ruby @ irc.freenode.net 中的某个人回答了它