Skip to main content
Code Review

Return to Answer

base 16 parsing
Source Link
200_success
  • 145.5k
  • 22
  • 190
  • 478

I would suggest interpreting the input as a number, then using standard number-formatting routines.

padded = str.format('0x{:08X}', int(mystring, 16))

The string → int → string round trip may seem silly, but it is also beneficial in that it provides validation of the input string.

I would suggest interpreting the input as a number, then using standard number-formatting routines.

padded = str.format('0x{:08X}', int(mystring))

The string → int → string round trip may seem silly, but it is also beneficial in that it provides validation of the input string.

I would suggest interpreting the input as a number, then using standard number-formatting routines.

padded = str.format('0x{:08X}', int(mystring, 16))

The string → int → string round trip may seem silly, but it is also beneficial in that it provides validation of the input string.

Post Undeleted by 200_success
Post Deleted by 200_success
Source Link
200_success
  • 145.5k
  • 22
  • 190
  • 478

I would suggest interpreting the input as a number, then using standard number-formatting routines.

padded = str.format('0x{:08X}', int(mystring))

The string → int → string round trip may seem silly, but it is also beneficial in that it provides validation of the input string.

lang-py

AltStyle によって変換されたページ (->オリジナル) /