我有一个100行、3年历史的Python爬虫程序,现在出现了bug。其中前几行如下:
import urllib, re, os, sys, time # line 1: import modules
os.chdir(os.path.dirname(sys.argv[0])) # line 2: all works in script's folder > relative address
# (rest of my script here!)
执行时,
$cd /my/folder/
$python script.py
我收到了以下错误:
python script.py
Traceback (most recent call last):
File "script.py", line 2, in <module>
os.chdir(os.path.dirname(sys.argv[0]))
OSError: [Errno 2] No such file or directory: ''
我该如何阅读这个错误信息以及应该怎么做?