我对Python非常陌生,我正在尝试如何减去用户输入的数组中的数字。例如,在我的计划的早期,我有:
`在
peakone = raw_input("Where is the next large peak?: ")
next_peak.append(peakone)
peaktwo = raw_input("Where is the next large peak?: ")
next_peak.append(peaktwo)
现在我要从peaktwo中减去peakone并将这个值保存为第三个值。如果有的话,最好的办法是什么?在
Tags:
你可以这样做:
从}。考虑这样编写代码:
^{pr2}$raw_input
得到的是一个字符串,因此需要将其转换为数值类型,如float
或{将
next_peak
设置为list
将输入转换为
int
或float
如果需要,可以将
int
更改为float
相关问题 更多 >
编程相关推荐