- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Converting hexadecimal integer to string in NetMRI python
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020 07:21 AM
Hello,
I am having difficulty converting an hexadecimal value in python with NetMRI. Any help would be appreciated.
The initial hex value is stored in a NetMRI List. Using the easy.get_list_value() function, the hex (integer) value is returned via python. To convert the hex integer to a string, I tried the following code:
parent_mh = easy.get_list_value(Spectrum_site_list, "MName", site_container, "MHandle", "NOTFOUND")
parent_mh_string = hex(parent_mh) ## also tried: parent_mh_string = hex(int(parent_mh))
But I get this error:
TypeError: 'str' object cannot be interpreted as an integer
Python script has returned 1 value
***
In a RHLpython environment environment, I can convert a hex integer to string:
>>> b = 0x106b52e
>>> hex(int(b))
'0x106b52e'
>>> hex(0x106b52e)
'0x106b52e'
>>> type(hex(0x106b52e))
<class 'str'>