我需要在字符串中提取两个数字。它们看起来像这样:
(0,0)
(122,158)
(1,22)
(883,8)
etc...
所以我想获取逗号前的第一个数字和逗号后的数字,并将它们存储在变量中。我可以这样得到第一个数字:
myString.split(',')[0][1:])
但是,我不知道如何获得下一个数字。
Thanks for the help everyone!
最佳答案
它应该与类似的东西一起工作
myVar.split(',')[0][1:] # = 122 for the string in the second line
myVar.split(',')[1][:-1] # = 158 for the string in the second line
这应该是最简单的方法
关于python - 从字符串中获取两个数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41952028/