python: Print Table on console in Python
# encoding: utf-8 # 版权所有 2024 ©涂聚文有限公司 # 许可信息查看:Python String | ljust(), rjust(), center() # 描述: # Author : geovindu,Geovin Du 涂聚文. # IDE : PyCharm 2023.1 python 3.11 # OS : windows 10 # Datetime : 2024/10/28 22:08 # User : geovindu # Product : PyCharm # Project : IctGame # File : student.py # explain : 学习 stuData = [[1, 'geovindu', '0002', '2008-01-03', 56,88,25], [2, 'jason', '0001', '2007-02-13', 63,88,25],[3, 'ada', '0003', '2008-02-14', 71,88,25] , [4, 'link', '0004', '2007-03-14', 50,88,25], [5, 'dus', '0005', '2007-02-12', 60,88,25], [6, 'bike', '0006', '2007-02-14', 77,88,25] , [7, 'eson', '0007', '2007-04-14', 57,88,25], [8, 'fok', '0008', '2007-02-11', 67,88,25],[9, 'hosrse', '0009', '2006-02-14', 70,88,25] , [10, 'ken', '0011', '2007-05-14', 52,88,25], [11, 'red', '0021', '2007-02-10', 62,88,25],[12, 'mike', '0031', '2005-02-14', 73,88,25] , [13, 'nike', '0012', '2007-06-14', 27,88,25], [14, 'queen', '0022', '2007-02-24', 65,88,25], [15, 'pen', '0023', '2004-02-14', 72,88,25] , [16, 'yelu', '0033', '2007-07-14', 22,88,25], [17, 'zoon', '0043', '2007-02-23', 64,88,25],[18, 'work', '0051', '2003-02-14', 76,88,25] , [19, 'ven', '0061', '2007-08-14', 53,88,25], [20, 'tesk', '0071', '2007-02-22', 61,88,25],[21, 'ilove', '0081', '2002-02-14', 75,88,25] , [22, 'open', '0091', '2007-09-14', 54,88,25], [23, 'seeek', '0092', '2007-02-21', 68,88,25],[24, 'uluko', '0028', '2009-02-14', 79,88,25] , [25, 'xero', '0101', '2007-10-14', 51,88,25], [26, 'xoo', '0201', '2007-02-20', 66,88,25],[27, 'yyeluey', '0301', '2017-02-14', 71,88,25] , [28, 'shenzhen', '0401', '2007-12-14', 50,88,25], [29, 'guanzhou', '0501', '2007-02-19', 69,88,25],[30, 'beiking', '0601', '2014-02-14', 70,88,25] , [31, 'qinhua', '0701', '2007-11-14', 56,88,25], [32, 'nanchang', '0001', '2007-02-18', 60,88,25],[33, 'jian', '0801', '2015-02-14', 74,88,25] ] print("┌{:<20s}┬{:<20s}┬{:<20s}┬{:<20s}┬{:<20s}┬{:<20s}┬{:<20s}┐".format("─" * 20, "─" * 20, "─" * 20,"─" * 20, "─" * 20, "─" * 20, "─" * 20)) Title = "│{:<20s}│{:<20s}│{:<20s}│{:<20s}│{:<20s}│{:<20s}│{:<20s}│".format('Id','StudentName ','StudentNO','StudentDate',' englishScore',' chineseScore',' mathScore') print(Title) print("├{:<20s}┼{:<20s}┼{:<20s}┼{:<20s}┼{:<20s}┼{:<20s}┼{:<20s}┤".format("═"* 20, "═"* 20, "═"* 20,"═"* 20, "═"* 20, "═"* 20, "═"* 20)) i=1 for Id,StudentName,StudentNO,StudentDate,englishScore,chineseScore,mathScore in stuData: print("│{:<20s}│{:<20s}│{:<20s}│{:<20s}│{:<20s}│{:<20s}│{:<20s}│".format(str(Id).center(20), StudentName.center(20), StudentNO.center(20), StudentDate.center(20), str(englishScore).center(20), str(chineseScore).center(20), str(mathScore).center(20))) if i<len(stuData): print("├{:<20s}┼{:<20s}┼{:<20s}┼{:<20s}┼{:<20s}┼{:<20s}┼{:<20s}┤".format("─" * 20, "─" * 20, "─" * 20, "─" * 20, "─" * 20, "─" * 20, "─" * 20)) i=i+1 print("└{:<20s}┴{:<20s}┴{:<20s}┴{:<20s}┴{:<20s}┴{:<20s}┴{:<20s}┘".format("─" * 20, "─" * 20, "─" * 20, "─" * 20, "─" * 20, "─" * 20, "─" * 20))
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)