不要理解这个无效的参数错误

时间:2017-06-07 23:51:45

标签: python json python-3.x

Traceback (most recent call last):
  File "C:\Users\한찬희\Desktop\졸업작품\indexer_test1.py", line 191, in 
<module>
    with open('./searchJson2.json/') as data_file:
OSError: [Errno 22] Invalid argument: './searchJson2.json/

Folder contents screenshot

code screenshot

2 个答案:

答案 0 :(得分:0)

因为路径不正确。删除尾部斜杠。

应该是:

  

以open(&#39; ./ searchJson2.json&#39;)作为data_file:

答案 1 :(得分:0)

你可以试试这个:

dir_path = os.path.dirname(os.path.realpath(__file__))
with open('{0}/searchJson2.json'.format(dir_path),'r+') as data_file: