tuple_numbertuple_numberTupleNumberTupleNumbertuple_number (算子名称)

名称

tuple_numbertuple_numberTupleNumberTupleNumbertuple_number — Convert a tuple (of strings) into a tuple of numbers.

参数签名

tuple_number( : : T : Number)

Herror tuple_number(const char* T, double* Number)

Herror T_tuple_number(const Htuple T, Htuple* Number)

void TupleNumber(const HTuple& T, HTuple* Number)

HTuple HTuple::TupleNumber() const

static void HOperatorSet.TupleNumber(HTuple t, out HTuple number)

HTuple HTuple.TupleNumber()

def tuple_number(t: MaybeSequence[Union[float, int, str]]) -> Sequence[Union[float, int, str]]

def tuple_number_s(t: MaybeSequence[Union[float, int, str]]) -> Union[float, int, str]

描述

tuple_numbertuple_numberTupleNumberTupleNumberTupleNumbertuple_number converts the input tuple TTTTtt into a tuple of numbers. If the input tuple contains numbers, they are simply copied into the output tuple. Strings are converted into the appropriate type of number (integer or floating point numbers) or are copied as strings if they do not represent a number. Note that strings starting with 0x are interpreted as hexadecimal numbers, and strings starting with 0 as octal numbers. For example, the string '20' is converted to the integer 20, '020' to 16, and '0x20' to 32.

Exception: Empty input tuple

If the input tuple is empty, 该算子 returns an empty tuple.

Exception: Out of range integers

If the input tuple contains strings with integers that cannot be represented as Hlong (32-bit signed integer for 32-bit HALCON, 64-bit signed integer for 64-bit HALCON), an exception is raised.

String padding

If tuple_numbertuple_numberTupleNumberTupleNumberTupleNumbertuple_number converts a string to a number, the same string with added leading and/or trailing spaces will be converted to the same number. Example: number('55.6') == 55.6 and number(' 55.6 ') == 55.6

HDevelop In-line Operation

HDevelop provides an in-line operation for tuple_numbertuple_numberTupleNumberTupleNumberTupleNumbertuple_number, which can be used in an expression in the following syntax:

Number := number(T)

运行信息

参数表

TTTTtt (input_control)  tuple(-array) HTupleMaybeSequence[Union[float, int, str]]HTupleHtuple (string / real / integer) (string / double / int / long) (HString / double / Hlong) (char* / double / Hlong)

Input tuple.

NumberNumberNumberNumbernumbernumber (output_control)  tuple(-array) HTupleSequence[Union[float, int, str]]HTupleHtuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (double / Hlong / char*)

Input tuple as numbers.

参考其它

tuple_is_numbertuple_is_numberTupleIsNumberTupleIsNumberTupleIsNumbertuple_is_number, tuple_stringtuple_stringTupleStringTupleStringTupleStringtuple_string

模块

Foundation