python 怎么去掉列表内一组数的单引号
['-57','13','46','-59','0','32','27','49','11','-12','-10','-42','-39']变成[-57,13,46,-...
['-57', '13', '46', '-59', '0', '32', '27', '49', '11', '-12', '-10', '-42', '-39'] 变成[-57,13,46,-59,0,32,27,49,11,-12,-10,-42,-39]
展开
展开全部
方法1
numbers = ['-57', '13', '46', '-59', '0', '32', '27', '49', '11', '-12', '-10', '-42', '-39']
print(numbers)
for i, v in enumerate(numbers):
numbers[i] = int(v)
print(numbers)
方法2:
numbers = ['-57', '13', '46', '-59', '0', '32', '27', '49', '11', '-12', '-10', '-42', '-39']
print(numbers)
numbers = [ int(x) for x in numbers ]
print(numbers)
方法3:
numbers = ['-57', '13', '46', '-59', '0', '32', '27', '49', '11', '-12', '-10', '-42', '-39']
newNumbers = []
for s in numbers:
newNumbers.append(int(s))
print(newNumbers)
numbers = ['-57', '13', '46', '-59', '0', '32', '27', '49', '11', '-12', '-10', '-42', '-39']
print(numbers)
for i, v in enumerate(numbers):
numbers[i] = int(v)
print(numbers)
方法2:
numbers = ['-57', '13', '46', '-59', '0', '32', '27', '49', '11', '-12', '-10', '-42', '-39']
print(numbers)
numbers = [ int(x) for x in numbers ]
print(numbers)
方法3:
numbers = ['-57', '13', '46', '-59', '0', '32', '27', '49', '11', '-12', '-10', '-42', '-39']
newNumbers = []
for s in numbers:
newNumbers.append(int(s))
print(newNumbers)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询