Hallo,
ich bin relativ neu in Python 3 und verstehe die Fehlermeldung nicht:
Ich habe eine Funktion die 2 Strings und eine Integer zurückgeben sollte:
>>> from time import *
def TimeString():
t=localtime()
#print (t)
d ='%02i%02i%02i' % (t.tm_year,t.tm_mon,t.tm_mday)
t ='%02i%02i%02i' % (t.tm_hour,t.tm_min,t.tm_sec)
print(t.tm_wday) # debug
dw= t.tm_wday
print (dw) # debug
#dw=-1
d=d[2:]
return (d,t,dw)
und wenn ich das Ding aufrufe:
>>> print (TimeString())
Traceback (most recent call last):
File "<pyshell#29>", line 1, in <module>
print (TimeString())
File "<pyshell#28>", line 6, in TimeString
dw= t.tm_year
AttributeError: 'str' object has no attribute 'tm_year'
Und wenn ich die einzelnen Zeilen einzeln ausführe .... funktioniert es... :s
Bitte um einen Hinweis was ich falsch mache.
Ich Danke Euch
Gottfried