First, val (character expression)
Val () is used to convert the digital part of a set of character data into corresponding numerical data.
Val () function usage:
1. Example x = "125fdsada456";
Then val(x) should be returned to 125, and the following 456 cannot be returned.
The val () function stops reading strings when it recognizes non-numbers. That is, if there are letters or other non-numeric characters in the string, the val () function only converts the numbers before the first non-numeric character. When the first character of the string is non-numeric, the return value is 0.
But this function can recognize binary symbols such as octal and hexadecimal. Spaces and line breaks in the string are also removed from this parameter.
2. Example a = "five stars";
b = 3;
It is obviously wrong to operate A+B. If you want to get the return value of 8, you should use the val () function.
c = val(a)+b; At this time, the value of c is 8.
Two. Val(C,V,Site)
Function: Convert the string C to the same numeric type as V, and assign the converted result to V. If there are non-numbers in the string, V=0. Site is used to return the position of non-numeric characters.
Python tutorial is recommended.