|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Turning Chr() Around.
I need my application to have something that works like Asc() does in VB6. This is the exact opposite of Chr(). Instead of using chr() to get me the number of a certain character(s), I need something like Asc() to give me back the numbers instead of the character(s).
|
|
#2
|
||||
|
||||
|
Use the ord() function, or define your own asc function.
Code:
def asc(c):
return ord(c)
print asc('A')
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month |
|
#3
|
||||
|
||||
|
__________________
*** Experimental Python Markup CGI V2 *** |
|
#4
|
||||
|
||||
|
Quote:
If you want to create copies/aliases to built-in functions/modules/classes using custom names the simplest way to do it is to assign the object to a variable i.e. Code:
>>> someChar = chr(97) >>> someChar 'a' >>> asc = ord >>> ord(someChar) 97 >>> asc(someChar) 97 >>> Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Turning Chr() Around. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|