检查python中变量的状态(Check the status of a variable in python)
我试图用if语句进行审计,尽管播放列表包含单词'http',但playlist should have value 'http: //*********/****.m3u ',但如果播放列表不包含包含单词'http',那么我想要有值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 playlistI 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最满意答案
你可以颠倒你的条件,并这样做:
def GETPLAYLIST(): playlistset = int(addon.getSetting('playlistset')) + 1 playlist = addon.getSetting('playlist' + str(playlistset)) if not 'http' in playlist: playlist = "file:///" + playlist return playlistYou 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更多推荐
发布评论