我的代码如下:
# Hello World program in Python
def timesummer(str1):
str2="."
location=str1.find(str2,)
location=location-1
location1=int(location)
strmin=str1[0,location]
float1=float(strmin)
minutes=int(float1)
location=location+1
strsec=str1[location,len(str1)-1]
float2=float(strsec)
seconds=int(seconds)
finalanswer=seconds+(minutes*60)
return finalanswer
print timesummer("1.10")
当我运行它时,它在strmin=str1[0,位置] 无效,因为我使用的是元组值? 如何修复代码? 我使用的是元组值吗?你知道吗
切片使用冒号,而不是逗号:
(另外,您可以省略0。)
相关问题 更多 >
编程相关推荐