# 某班有N个学生,现在要选出M人(Mimport random def select(n, m): num = [i for i in range(n)] num = random.sample(num, m) return num if __name__ == '__main__': all_classmates = int(input('请输入班级总人数:')) sel_classmates = int(input('请输入总选择人数:')) print('已选出以下编号的同学:', *select(all_classmates, sel_classmates))