1、现在有如下流程:A->B->C->D->E->F,要求根据输入的参数从制定的流程执行下去
"""
File: 01流程执行.py
Author: chde_wang
Date: 2020-08-16 18:51:35
Description:将输入存储到列表中,方便判断下一输入是否为之前的第二阶段,当前一阶段满足且输入为F时,输入结束
"""
import sys
process_list = ['A', 'B', 'C', 'D', 'E', 'F']
input_list = []
while True:print("若要退出请按quit!")input_char = input("请输入流程:")if input_char == 'quit':sys.exit()else:if input_char in process_list:for char_name in input_char:if char_name == 'A':input_list.append(char_name)print("下一流程为B")elif char_name == 'B' and input_list[-1] == 'A':input_list.append(char_name)print("下一流程为C")elif char_name == 'C' and input_list[-1] == 'B':input_list.append(char_name)print("下一流程为D")elif char_name == 'D' and input_list[-1] == 'C':input_list.append(char_name)print("下一流程为E")elif char_name == 'E' and input_list[-1] == 'D':input_list.append(char_name)print("下一流程为F")elif char_name == 'F' and input_list[-1] == 'E':input_list.append(char_name)print("流程结束")sys.exit()else:print("输入错误!", end='')else:print("输入错误,请重新输入!若要退出请按quit!")
2、数据库题目:数据库记录行转列
现有数据库记录如下:
实现方式1-静态max实现:
SELECT`Name`,max( CASE WHEN SUBJECT = '语文' THEN Score ELSE 0 END ) AS 语文,max( CASE WHEN SUBJECT = '数学' THEN Score ELSE 0 END ) AS 数学,max( CASE WHEN SUBJECT = '英语' THEN Score ELSE 0 END ) AS 英语,max( CASE WHEN SUBJECT = '生物' THEN Score ELSE 0 END ) AS 生物
FROMtest_a
GROUP BYNAME;
实现方式2-静态sum实现:
SELECT`Name`,sum( CASE WHEN SUBJECT = '语文' THEN Score ELSE 0 END ) AS 语文,sum( CASE WHEN SUBJECT = '数学' THEN Score ELSE 0 END ) AS 数学,sum( CASE WHEN SUBJECT = '英语' THEN Score ELSE 0 END ) AS 英语,sum( CASE WHEN SUBJECT = '生物' THEN Score ELSE 0 END ) AS 生物
FROMtest_a
GROUP BYNAME;
实现方式3-动态实现: