A.M said:
Hi,
I am trying to find the equivalent functions such as vb's str or asc in
Python. Is there any resource that help me to find these kinds of functions
in Python faster?
Thank you,
Alan
Python has a str() function that is close to vb's str. The Python
version does not produce a leading space.
str(123) --> '123'
If you want to control the formatting to mimick vb or create different
formatting you can use.
" %d" % 123 --> ' 123'
The format specifier is just like 'C's printf format strings.
A tuple should follow the % sign if formatting more than 1 number.
"%d %d" % (123, 456)
Python has a similar function to vb's asc.
It is ord().
ord() accepts a single character, whereas asc operates on the first
character of a string.
To mimick vb you could do
s = 'hello'
ord(s[0]) --> 104
I am unaware of any reference associating vb functionality with Python
functionality.
Then again, I never looked for one.