Passing strings from Python Integration Toolkit for Labview, to Python functions

The biggest single difference between Python 2 and Python 3 is the change in the string model from 1-byte chars to variable-byte unicode. This accounts for most difficulties when converting code from Python 2 to Python 3; string-handling Python code will generally need to change to account for this.

Strings from LabVIEW are always passed by the Toolkit to Python as an object of type byte. Assuming that the string is actually an ASCII string, just use s.decode('ascii') at the top of the Python function. On Python 3, this will give you a strobject (which is always unicode as mentioned above) , and in Python 2, this will give you a unicode object.

 

Please do not enter support requests in article comments

Please use article comments for suggestions to improve the article. For individual support requests, please follow these guidelines.

Have more questions? Submit a request

Comments

Powered by Zendesk