python - 当我运行我的代码时,输出对齐不准确,
问题描述
from math import *
import numpy
element = {"1111":"The way", "1110":"Tail of the Dragon","1101":"The Boy","1100": "The Lesser Fortune","1011":"The Girl","1010":"Loss","1001":"The Prison","1000":"Joy","0111":"Head of the Dragon","0110":"The Conjuction","0101":"Gain","0100":"Red","0011":"Greater Fortune","0010":"White","0001":"Sorrow","0000":"People"}
z_array =[ ]
asia=["Life","Riches","Brothers","Father","Sons","Health","Spouse","Death","Journeys","Kings", "Good Fortune","Prison","Witness 1","Witness 2","Judge","Reconciler"]
for b in range(16):
first =str(input(""))
z_array.append(first)
europe_country =["",z_array[10],z_array[9],z_array[8],z_array[7],z_array[3],z_array[2],z_array[1],z_array[0],z_array[12],z_array[11],z_array[5],z_array[4],z_array[13],z_array[6],
z_array[14],z_array[15],]
print("House"+"\t"+"\t"+"Name"+"\t"+"\t"+"Symbol")
for b in range(1,17):
asia1 = str(asia[b-1])
country = "street"
if len(asia1)>=8:
print(str(b)+"\t"+"\t"+str(asia[b-1])+"\t"+str(element[europe_country[b]]))
else:
print(str(b)+"\t"+"\t"+str(asia[b-1])+"\t"+"\t"+str(element[europe_country[b]]))
当我尝试运行脚本时输出对齐不准确,请帮我解决这个问题。
我在上面添加了我的代码。
谢谢!
解决方案
我对上面的代码做了一些小的改动,但这些都不是必须的。如果我不进行这些更改,那么也没有问题。我在运行代码时传递了以下输入,
1111
1101
1010
1000
1010
1110
0001
0101
0011
0101
0000
1111
1110
0001
1010
0101
我得到的以下输出格式正确,我猜,
House Name Symbol
1 Life People
2 Riches Gain
3 Brothers Greater Fortune
4 Father Gain
5 Sons Joy
6 Health Loss
7 Spouse The Boy
8 Death The way
9 Journeys Tail of the Dragon
10 Kings The way
11 Good Fortune Tail of the Dragon
12 Prison Loss
13 Witness 1 Sorrow
14 Witness 2 Sorrow
15 Judge Loss
16 Reconciler Gain
如果上述格式不可接受,请传递上述输入并让我知道您的预期输出。这样我才能帮助你。
推荐阅读
- deep-learning - PyTorch 不会使初始权重随机化
- seo - 使用 jpg 后备时,PageSpeed Insights 无法识别 WebP 格式
- axapta - 使用 D365FO 中的查找更新网格
- javascript - 用firebase等待谷歌登录并显示隐藏html的东西
- node.js - 是否可以将消息存储在 socketio 聊天应用程序中
- html - 我正在尝试对多个 JSP 页面使用相同的 css 文件,但它只能在一个页面中工作。为什么?
- reactjs - 将 Socket.io 实现到下一个 js 的无服务器/vercel 部署中?
- java - 为什么 GregorianCalendar 在日期末尾随机添加“Z”,有时不添加
- r - 在 R 中跨网站跟踪用户会话
- python - 为 for 循环的每次迭代创建新列表