[Python] Print input and output in table
Print the input and output in a table using prettyTable.
from prettytable import PrettyTable
import collections def printTableResult(variables, count):
inputList = collections.defaultdict(list)
outputList = collections.defaultdict(list)
resultTable = PrettyTable() for variable in variables:
if variable.type == "input":
inputList[variable.variable_id] = variable.values
length = len(variable.values)
elif variable.type == "output":
outputList[variable.variable_id] = variable.values logIdColumn = []
outputSepColumn = []
for i in range(count):
logIdColumn.append(i)
outputSepColumn.append("")
resultTable.add_column("Run ID", logIdColumn) for each in inputList:
column = []
for i in range(count):
column.append(inputList[each][i].value)
resultTable.add_column(each,column)
resultTable.add_column("output", outputSepColumn)
for each in outputList:
column = []
for i in range(count):
column.append(outputList[each][i].value)
resultTable.add_column(each, column) print(resultTable)
[Python] Print input and output in table的更多相关文章
- Python - 3. Input and Output
from:http://interactivepython.org/courselib/static/pythonds/Introduction/InputandOutput.html Input a ...
- [译]The Python Tutorial#7. Input and Output
[译]The Python Tutorial#Input and Output Python中有多种展示程序输出的方式:数据可以以人类可读的方式打印出来,也可以输出到文件中以后使用.本章节将会详细讨论 ...
- Python Tutorial 学习(七)--Input and Output
7. Input and Output Python里面有多种方式展示程序的输出.或是用便于人阅读的方式打印出来,或是存储到文件中以便将来使用.... 本章将对这些方法予以讨论. 两种将其他类型的值转 ...
- 7. Input and Output
7. Input and Output There are several ways to present the output of a program; data can be printed i ...
- [20171128]rman Input or output Memory Buffers.txt
[20171128]rman Input or output Memory Buffers.txt --//做一个简单测试rman 的Input or output Memory Buffers. 1 ...
- Java中的IO流,Input和Output的用法,字节流和字符流的区别
Java中的IO流:就是内存与设备之间的输入和输出操作就成为IO操作,也就是IO流.内存中的数据持久化到设备上-------->输出(Output).把 硬盘上的数据读取到内存中,这种操作 成为 ...
- 标准库 - 输入输出处理(input and output facilities) lua
标准库 - 输入输出处理(input and output facilities)责任编辑:cynthia作者:来自ITPUB论坛 2008-02-18 文本Tag: Lua [IT168 技术文档] ...
- C lang:character input and output (I/O)
Xx_Introduction Character input and output is by more line character conpose of the text flow Defin ...
- 给定一个字符串,把字符串内的字母转换成该字母的下一个字母,a换成b,z换成a,Z换成A,如aBf转换成bCg, 字符串内的其他字符不改变,给定函数,编写函数 void Stringchang(const char*input,char*output)其中input是输入字符串,output是输出字符串
import java.util.Scanner; /*** * 1. 给定一个字符串,把字符串内的字母转换成该字母的下一个字母,a换成b,z换成a,Z换成A,如aBf转换成bCg, 字符串内的其他字 ...
随机推荐
- Asp.Net任务Task和线程Thread
Task是.NET4.0加入的,跟线程池ThreadPool的功能类似,用Task开启新任务时,会从线程池中调用线程,而Thread每次实例化都会创建一个新的线程.任务(Task)是架构在线程之上的, ...
- Spring Boot 调用 MongoRepository时报org.springframework.beans.factory.NoSuchBeanDefinitionException错误的解决办法
这个问题整整折腾了我两天,现在记录下来,希望可以帮助和我一样,遇到相同问题的小伙伴. 项目是分层的(Intellij IDEA中的模块Module),有API(Core)层,Service&D ...
- window、Linux 文本文件转换
如下: $ sed -e 's/.$//' mydos.txt > myunix.txt $ sed -e 's/$/\r/' myunix.txt > mydos.txt
- Zend Optimizer,Zend Guard Loader 和 Zend Opcache 三者之间的区别
PHP的加速插件有三个:Zend Optimizer.Zend Guard Loader 和 Zend Opcache.但其实都是一个,针对不通的php版本.名字叫法不一样而已. Zend Optim ...
- Springboot中如何在Utils类中使用@Autowired注入bean
Springboot中如果希望在Utils工具类中,使用到我们已经定义过的Dao层或者Service层Bean,可以如下编写Utils类: 1. 使用@Component注解标记工具类Statisti ...
- 10.Oracle Golden Date(ogg)的搭建和管理
一. GoldenGate 概述 GoldenGate现在是业内成熟的数据容灾与复制产品:GoldenGate是一种基于日志的结构化数据复制方式,它通过解析源数据库在线日志或归档日志获得数据的增删改变 ...
- git使用git-credential-winstore保存https访问密码
使用 https 方式 clone 一个 git 仓库,每次pull 或者 push 的时候都需要输入用户名和密码. 访问远程Git仓库可以用 SSH 方式和 https 方式,https 每次访问时 ...
- 【Linux常用工具】
tmux - 终端分屏工具 man - Help cat/more/less - 文件阅读 less还具有字符串搜索功能
- IE8下动态生成option无法设置文本内容
问题: 1.在IE8下,JS动态添加 option 的时候,value 有值,但是文本内容添加不上 例:<option value="北京"></option&g ...
- M - COURSES
Consider a group of N students and P courses. Each student visits zero, one or more than one courses ...