简体   繁体   中英

Check the status of a variable in python

I am trying to conduct an audit with if statement, though playlist contains the word 'http', playlist should have value 'http: //*********/****.m3u but if playlist does not contain the word 'http' then I would like to have the value playlist '"file: ///" + playlist'

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

You could invert your condition and do this way:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM