标签:结果 app school nbsp result temp db_name pre span
获取数据库列表屏蔽系统自带数据库
# 原代码 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‘]
标签:结果 app school nbsp result temp db_name pre span
原文地址:https://www.cnblogs.com/leoshi/p/12310640.html