Python错误IOError:[Errno 2]没有这样的文件或目录:

Python错误IOError:[Errno 2]没有这样的文件或目录:,python,errno,ioerror,Python,Errno,Ioerror,这是我的剧本 from bs4 import BeautifulSoup import requests import sys import os givenURL = raw_input("Entrer votre liens ") headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0

这是我的剧本

    from bs4 import BeautifulSoup
import requests
import sys
import os


givenURL = raw_input("Entrer votre liens ")


headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}

# initialize session
session = requests.Session()

# getting playlist
response = session.get(givenURL, headers=headers)
soup = BeautifulSoup(response.content)
playlist = soup.find('a', {'data-playlist': True})['data-playlist']
oname = soup.find("title")
oname.text
print oname.text 

# getting list of videos
url = 'http://animedigitalnetwork.fr/index.php?option=com_vodvideo&view=playlist&format=raw'
response = session.post(url, data={
    'playlist': playlist,
    'season': '',
    'order': 'DESC'
}, headers=headers)

soup = BeautifulSoup(response.content)
path = os.path.join('Playlist', oname.text)
with open(path, 'w') as f:
    for video in soup.select('div.adn-video'):
        s = 'http://www.animedigitalnetwork.fr' + video.a.get('href')
        f.write(s + '\n')

# Read the file, and break after printing the first line.        
with open(path) as f:
    for line in f:
        print line.rstrip()
        break
我的脚本出错了

Traceback (most recent call last):
  File "adnplay.py", line 33, in <module>
    with open(path, 'w') as f:
IOError: [Errno 2] No such file or directory: u'Playlist/Maria, Sorci\xe8re de gr\xe9, pucelle de force ! - VOSTFR'
回溯(最近一次呼叫最后一次):
文件“adnplay.py”,第33行,在
打开(路径“w”)作为f:
IOError:[Errno 2]没有这样的文件或目录:u'Playlist/Maria,Sorci\xe8re de gr\xe9,pucelle de force!-VOSTFR'
我使用这个脚本来检索该站点的播放列表,但我不知道如何修复该脚本,因为我以前没有问题

我不理解这个错误

我真的需要你的帮助


提前下载

是否有名为“播放列表”的文件夹?如果没有,则需要创建一个。
path
中的filepath字符串与磁盘上的实际有效目录路径不对应。获取
路径的值
,然后手动尝试在那里导航。