Hallo zusammen
Ich versuche auch mein eigenes Programm zu schreiben. Leider bekomme ich de selbe Fehlermeldung. Versuche nun schon seit längerem auf eine Lösung zu kommen, nur leider stehe ich voll auf dem Schlauch und schaffe es einfach nicht. Hoffe jemand hier kann mir helfen.
Mein Code:
Code: Alles auswählen
import json
import os
togr650 = {}
togr550 = {}
togr450 = {}
tod650 = {}
tod550 = {}
tod450 = {}
dict_names = ("to_gr_650.json", "to_gr_550.json","to_gr_450.json", "to_d_650.json", "to_d_550.json", "to_d_450.json")
as_names = (os.path("gr650"), os.path("gr550"), os.path("gr450"), os.path("d650"), os.path("d550"), os.path("d450"))
dicts = (togr650, togr550, togr450, tod650, tod550, tod450)
def fix_floats(data):
if isinstance(data,list):
iterator = enumerate(data)
elif isinstance(data,dict):
iterator = data.items()
else:
raise TypeError("can only traverse list or dict")
for i,value in iterator:
if isinstance(value,(list,dict)):
fix_floats(value)
elif isinstance(value,str):
try:
data[i] = float(value)
except ValueError:
pass
for num, d in enumerate(zip(dict_names),1):
for num, a in enumerate(zip(as_names),1):
for num, d2 in enumerate(zip(dicts),1):
with open(d, "r") as a:
d2 = fix_floats(json.load(a))
print(d2)
Die Fehlermeldung sieht wie folgt aus:
Code: Alles auswählen
Traceback (most recent call last):
File "<ipython-input-15-747a58840eb2>", line 1, in <module>
runfile('C:/Users/***/Desktop/Python Tecnam Projekt/untitled1.py', wdir='C:/Users***/Desktop/Python Tecnam Projekt')
File "C:\Users\***\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users***\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/***/Desktop/Python Tecnam Projekt/untitled1.py", line 21, in <module>
as_names = (os.path("gr650"), os.path("gr550"), os.path("gr450"), os.path("d650"), os.path("d550"), os.path("d450"))
TypeError: 'module' object is not callable
Vielen Dank schon jetzt für eure Hilfe.
LG Kevin