2017-02-24 87 views
0

我試圖用if語句進行審計,雖然播放列表包含單詞'http',playlist should have value 'http: //*********/****.m3u但如果播放列表不包含單詞'http',那麼我想要值playlist '"file: ///" + playlist'檢查python中的變量的狀態

def GETPLAYLIST(): 
    playlistset = int(addon.getSetting('playlistset')) + 1 
    playlist = addon.getSetting('playlist' + str(playlistset)) 
    if 'http' in 'playlist' 
    else: 
     playlistlist = "file:///" + playlist 
    return playlist 

回答

0

您可以反轉您的病情,做這種方式:

def GETPLAYLIST(): 
    playlistset = int(addon.getSetting('playlistset')) + 1 
    playlist = addon.getSetting('playlist' + str(playlistset)) 
    if not 'http' in playlist: 
     playlist = "file:///" + playlist 
    return playlist 
+0

錯誤:拋出異常(PythonToCppException): - > Python的回調/腳本返回以下錯誤< - - 注意:忽略這可能會導致內存泄漏! 錯誤類型: 錯誤內容:('預期縮進塊',('C:\\ Users \\ *** \ default.py',126,9,'playlist =「 file:///「+ playlist \ n')) - > Python腳本錯誤報告結束< - – Jonny

+0

縮進中存在一些錯誤,請檢查一切是否正確並與您當前的代碼符合' playlist =「file:///」+ playlist' – Marcos

+1

我仔細檢查過,我犯了一個語法錯誤,它的工作原理很棒。謝謝 – Jonny