我正在使用 soundcloud API 和 python,并尝试使用浏览器打开歌曲的 url。我用这个代码
client = soundcloud.Client(client_id=clientIdEntry.get())
track_url = urlEntry.get()
if track_url[0]!="h":
track_url = "https://"+urlEntry.get()
else:
track_url = urlEntry.get()
track = client.get('/resolve', url=track_url)
track_id = str(track.id)
track = client.get("/tracks/"+track_id)
stream_url = client.get(track.stream_url, allow_redirects=False)
print(track.title)
print("\n \n \n")
print(stream_url.location)
time.sleep(3)
os.system("chromium-browser "+stream_url.location)
但 URL 包含 & 字符,终端不会打开该符号后面的文本。谁能帮我?
答案1
尝试这个
os.system("chromium-browser '"+stream_url.location+"'")