我有一个 100 行、3 岁的 python 刮板,现在有问题。起跑线是:
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: ''
我应该如何阅读此错误以及该怎么做?