关于python中字符串的分割问题
test = "21 34"
我想得到21+34
当时想的方法是:
test.split()
int(test[0])+int(test[1])
试过之后发现有问题:
>>> test = "21 34"
>>> test.split()
['21', '34']
>>> test[0]
'2'
>>> test[1]
'1'
>>>
求正解.
[解决办法]
谢谢楼主
发布时间: 2012-09-15 19:09:28 作者: rapoo
关于python中字符串的分割问题
test = "21 34"
我想得到21+34
当时想的方法是:
test.split()
int(test[0])+int(test[1])
试过之后发现有问题:
>>> test = "21 34"
>>> test.split()
['21', '34']
>>> test[0]
'2'
>>> test[1]
'1'
>>>
求正解.
[解决办法]
谢谢楼主