What about this:
hex(dec).split('x')[-1]
Example:
>>> d = 30
>>> hex(d).split('x')[-1]
'1e'
By using -1 in the result of split(), this would work even if split returned a list of 1 element.
More Related Contents:
- Convert hex to float
- How do I convert hex to decimal in Python? [duplicate]
- Python function define: A message will prompt up if missing entering an argument
- Function defined correctly?
- Convert hex string to int in Python
- How can I return two values from a function in Python?
- range() for floats
- Ignore python multiple return value
- How to use a return statement in a for loop?
- How do I create a Python function with optional arguments?
- Which is more preferable to use: lambda functions or nested functions (‘def’)?
- Python Decimals format
- How can I use `return` to get back multiple values from a for loop? Can I put them in a list?
- Forced naming of parameters in Python
- How to timeout function in python, timeout less than a second
- Convert hex string to integer in Python
- Calling functions from a Tkinter Frame to another
- Add zeros to a float after the decimal point in Python
- Import a python module without running it
- What’s 0xFF for in cv2.waitKey(1)?
- Is it possible to change a function’s default parameters in Python?
- Python: function and variable with the same name
- How to apply a function to each sublist of a list in python?
- Accessing returned values from a function, by another function
- Reverse a string without using reversed() or [::-1]?
- “unpacking” a passed dictionary into the function’s name space in Python?
- Returning tuple with a single item from a function
- python function default parameter is evaluated only once? [duplicate]
- Python “decimal” package gives wrong results
- Store functions in list and call them later [duplicate]