用字符计算 [英] computing with characters
问题描述
如何用python中的字符整数值计算?
赞
''a''+ 1等于''b''等等
How can I compute with the integer values of characters in python?
Like
''a'' + 1 equals ''b'' etc
推荐答案
SL写道:
SL wrote:
如何用整数值计算python中的字符?
喜欢
''''+ 1等于''b''等
-
< a rel =nofollowhref =http://mail.python.org/mailman/listinfo/python-listtarget =_ blank> http://mail.python.org/mailman/listinfo/python-list
您可以使用ord()函数从字符中获取整数值。
Gary Herron
You can get an integer value from a character with the ord() function.
Gary Herron
你好,
2008/4/30 Gary Herron< gh ***** @ islandtraining.com>:
Hi,
2008/4/30 Gary Herron <gh*****@islandtraining.com>:
SL写道:
SL wrote:
如何用python中的字符整数值计算?
喜欢''a''+ 1等于''b''等等
How can I compute with the integer values of characters in python?
Like ''a'' + 1 equals ''b'' etc
您可以使用ord()函数从字符中获取整数值。
You can get an integer value from a character with the ord() function.
因此,只需完成,解决方案是:
So just for completion, the solution is:
>> chr(ord(''a'')+ 1)
>>chr(ord(''a'') + 1)
'' b''
Lutz
-
您想要Google Mail邀请吗?请给我发一封电子邮件!
''b''
Lutz
--
Do you want a Google Mail invitation? Just write me an email!
2008年4月30日星期三16:13:17 +1000,SL< ni@hao.comwrote:
On Wed, 30 Apr 2008 16:13:17 +1000, SL <ni@hao.comwrote:
如何计算python中字符的整数值?
类似''a''+ 1等于''b''等等
How can I compute with the integer values of characters in python?
Like ''a'' + 1 equals ''b'' etc
尝试:ord('''')
参见: http://aspn.activestate.com/ASPN/Coo...n/Recipe/65117
-
Kam-Hung Soh< a href =" http://kamhungsoh.com/blog">软件Salariman< / a>
Try: ord(''a'')
See also: http://aspn.activestate.com/ASPN/Coo...n/Recipe/65117
--
Kam-Hung Soh <a href="http://kamhungsoh.com/blog">Software Salariman</a>
这篇关于用字符计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!