Just for completeness, using the modern .format()
syntax:
>>> numbers = [1, 15, 255]
>>> ''.join('{:02X}'.format(a) for a in numbers)
'010FFF'
More Related Contents:
- Python, How to remove gaps between text and variable?
- How to prettyprint a JSON file?
- How do I keep Python print from adding newlines or spaces? [duplicate]
- String formatting in Python
- Formatting floats without trailing zeros
- Currency formatting in Python
- Format floats with standard json module
- Pandas: Setting no. of max rows
- Convert to binary and keep leading zeros
- Formatting timedelta objects [duplicate]
- Easy pretty printing of floats?
- formatting long numbers as strings in python
- How can I break up this long line in Python?
- Python datetime formatting without zero-padding
- Declare function at end of file in Python [duplicate]
- Format certain floating dataframe columns into percentage in pandas
- Formatting Complex Numbers
- Using variables in the format() function in Python
- Formatting long numbers as strings
- What does !r do in str() and repr()?
- What’s the best way to format a phone number in Python?
- Can you format pandas integers for display, like `pd.options.display.float_format` for floats?
- Unable to encode/decode pprint output
- How can I make a sprite move when key is held down
- How to one-hot-encode from a pandas column containing a list?
- Pandas counting and summing specific conditions
- Application not picking up .css file (flask/python) [duplicate]
- Show decimal places and scientific notation on the axis of a matplotlib plot
- openpyxl load_workbook() on a legit .xlsx file leads to a zipfile.BadZipFile error
- KeyError when indexing Pandas dataframe