-4
Ich habe den Code unten:Mein Python GUI sagte immer wieder ein int ein Tupel
# 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")
Und wenn ich es laufen, sagt es, dass bei strmin str1 = [0, location] ist nicht gültig, weil ich verwende einen Tupelwert? Wie repariere ich den Code? Verwende ich einen Tupelwert?
leider erste Mal mit statck Überlauf, nicht sicher, wie – Panda
# schreiben Hallo Weltprogramm in Python def mal summer (str1): str2 = "." location = str1.find (STR2,) location = location1 location1 = int (Ort) strmin str1 = [0, location] float1 = float (strmin) Minuten = int (float1) location = Ort + 1 strsec = str1 [Lage, len (sTR1) -1] float2 = float (strsec) Sekunden = int (Sekunden) finalanswer = Sekunden + (min * 60) return finalanswer Druck timesummer ("1.10") – Panda
Was erwarten Sie, wenn Sie 'strmin = str1 [0, lo Kation] '? Suchen Sie nach ':', dem Slice Operator? –