所以我有这段代码:
from urllib2 import *
import re
alist = []
mu = 'noah and the whale'
mus = mu.replace(' ','-')
op = urlopen('http://en.dilandau.eu/download_music/' + mus + '-1.html')
ops = op.read()
if 'charset="utf-8">var playlist' in ops:
print 'yes'
cal = ops.split('charset="utf-8">var playlist',1)
del cal[0]
asv.write(str(cal))
cv = str(cal)
cals = cv.split('},];</script><div',1)
del cals[1]
cals = str(cals)
v = cals.replace('{', '''
''')
vn = v.replace('[','')
vnm = vn.replace(']','')
parsed = re.findall('author : "([^"]+)",title : "([^"]+)",type : "([^"]+)",file : "([^"]+)",id : "([^"]+)', vnm)
cvb = ','.join(map(''.join,als)
canada = cvb.split('sound,',1)
song = canada[0]
del canada[0]
run = str(canada)
print run
def download():
url = "http://www.tittletunes.com/wp-content/uploads/08%20Stranger.mp3"
down = urlopen(url)
filepath = 'C:\Users\Psao\Music\Music\dow.mp3'
local = open(filepath, "wb")
local.write(down.read())
但是当我出于某种原因运行代码时,我收到了这个错误:
line 39 canada = cvbz.split('sound,',1) ^ SyntaxError: invalid syntax
答案 0 :(得分:5)
计算括号。任何体面的源代码编辑器都具有匹配大括号的功能。了解您的工具 - 使用您的工具 - 并详细检查您的错误消息。回溯清楚地告诉你错误在哪里 - 所以你下次更仔细地看看。
答案 1 :(得分:3)
你错过了
末尾的右括号)
cvb = ','.join(map(''.join,als)
答案 2 :(得分:0)
你错过了收盘):
cvb = ','.join(map(''.join,als)
答案 3 :(得分:0)
自:
cvb = ','.join(map(''.join,als)
要:
cvb = ','.join(map(''.join,als))
你忘记了右括号。