web開發(fā)是做網(wǎng)站搜索引擎推廣培訓(xùn)
with open(json_file, 'r') as f:data = json.load(f)
要寫個(gè)簡(jiǎn)單的數(shù)據(jù)處理腳本,報(bào)錯(cuò)AttributeError: ‘str’ object has no attribute ‘load’,查看了一下,路徑正確,查了半天博客,不知道錯(cuò)在哪里。
回頭一看
jsons_path = r"路徑"
images_path = r"路徑"
output_folder = r'路徑'
for json in os.listdir(jsons_path):if json.endswith('.json'):json_path = os.path.join(jsons_path, json)
函數(shù)外面循環(huán)中的全局變量命名為json,循環(huán)中進(jìn)入了報(bào)錯(cuò)的函數(shù)。
改個(gè)名字就好了
我是大sb