Python: OSError: [Errno 2] No such file or directory: ''

后端 未结 3 1684
鱼传尺愫
鱼传尺愫 2020-12-05 03:08

I have a 100 lines, 3 years old python scraper that now bug. Starting lines are:

import urllib, re, os, sys, time    # line 1: import modules
os.chdir(os.pat         


        
3条回答
  •  Happy的楠姐
    2020-12-05 03:32

    I had this error because I was providing a string of arguments to subprocess.call instead of an array of arguments. To prevent this, use shlex.split:

    import shlex, subprocess
    command_line = "ls -a"
    args = shlex.split(command_line)
    p = subprocess.Popen(args)
    

提交回复
热议问题