我需要从字符串类型转换为数字
list = ["-5","4","-3","variable"] # Input
list = [-5,4,-3,"variable"] # epected output
Run Code Online (Sandbox Code Playgroud)
我在转换负数时遇到问题
list[0]=int(list[0])
Run Code Online (Sandbox Code Playgroud)
ValueError:int() 的无效文字,基数为 10:'-5'