有没有什么好办法来获取字符串的第二位数呢?例如:
aaa = 122
bbb = 333
rest = bbb-aaa
if rest[:2] == 1:
do something..发布于 2013-12-17 01:44:17
首先使用内置的str()函数将整数转换为字符串,然后对其进行相应的切片
所以试试这个:
if str(rest)[1] == '1':
#do something example:
print 'hi'https://stackoverflow.com/questions/20617224
复制相似问题