检查python中变量的状态(Check the status of a variable in python)

编程入门 行业动态 更新时间:2024-10-28 06:28:23
检查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 playlist

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

最满意答案

你可以颠倒你的条件,并这样做:

def GETPLAYLIST(): playlistset = int(addon.getSetting('playlistset')) + 1 playlist = addon.getSetting('playlist' + str(playlistset)) if not 'http' in playlist: playlist = "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

更多推荐

本文发布于:2023-08-06 06:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1445257.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   状态   python   variable   status

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!