[python]List 过滤
获取数据库列表屏蔽系统自带数据库
# 原代码 db_list_result = [(‘master‘, ), (‘tempdb‘, ), (‘model‘, ), (‘msdb‘, ), (‘student‘, ), (‘school‘, )] db_list = [] for _database in db_list_result: if ‘master‘ in _database: continue if ‘tempdb‘ in _database: continue if ‘model‘ in _database: continue if ‘msdb‘ in _database: continue db_list.append(_database[0]) print(db_list) # 修改后代码 result2 = [db_name[0] for db_name in db_list_result if not (db_name[0] in [‘master‘,‘tempdb‘,‘model‘,‘msdb‘])] print(result2) #----输出结果------ [‘student‘, ‘school‘]
相关推荐
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20
weiiron 2020-11-16