有人可以帮我解决错误。我能够解决制表符/空格错误,但现在我遇到了此错误
root@test/tmp # python3 1.py
Traceback (most recent call last):
File "1.py", line 9, in <module>
del element['testdir']
TypeError: 'str' object does not support item deletion
1.py:
import json, subprocess, os, sys, shutil, time
from subprocess import Popen, PIPE
os.system('curl -s -u xxxxx > list.txt')
with open('list.txt') as data_file:
list = json.load(data_file)
for element in list:
del element['testdir']
for dir in list:
print('dir' + dir)