由于某种原因,在某些事情可以解决之前,我遇到了一个错误。有人可以告诉我这是什么问题。
import os
import json
for filename in os.listdir(os.getcwd()):
print(filename)
if '.json' in filename:
with open(filename, 'w') as y:
filename = filename[:-5]
json.dump({
"parent": "item/generated",
"textures": {
f"item/guildinterface/{filename}"
}
}, y)
if __name__ == '__main__':
main()
错误是
File "C:/Heights/Documents/Projects/yotam/3.7/plutto/test.py", line 19, in <module>
main()
File "C:/Heights/Documents/Projects/yotam/3.7/plutto/test.py", line 15, in main
}, y)
File "C:\Users\yotam\AppData\Local\Programs\Python\Python37-32\lib\json\__init__.py", line 179, in dump
for chunk in iterable:
File "C:\Users\yotam\AppData\Local\Programs\Python\Python37-32\lib\json\encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "C:\Users\yotam\AppData\Local\Programs\Python\Python37-32\lib\json\encoder.py", line 405, in _iterencode_dict
yield from chunks
File "C:\Users\yotam\AppData\Local\Programs\Python\Python37-32\lib\json\encoder.py", line 438, in _iterencode
o = _default(o)
File "C:\Users\yotam\AppData\Local\Programs\Python\Python37-32\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type set is not JSON serializable