嘿伙计们,我需要一些帮助来对齐我的整数。我将向您展示我的代码是什么,我的输出是什么,以及我希望我的输出是什么。谢谢!
代码:
test_sign='#'
test_numbers=[100000,5000000,7000000]
test_calc_list=[]
test_sum=sum(test_numbers)
test_list=['Testcase1','Testcase2','Testcase3']
test_sign_list=[]
for x in test_numbers:
test_calc=round((x/float(test_sum)*10))
test_calc_list.append(test_calc)
for y in test_calc_list:
y=int(y)
signs=y*test_sign
test_sign_list.append(signs)
for z in range(len(test_list)):
print "%8s"%test_list[z]+":",test_sign_list[z],test_numbers[z]
输出:
Testcase1: 100000
Testcase2: #### 5000000
Testcase3: ###### 7000000
期望的输出:
Testcase1: 100000
Testcase2: #### 5000000
Testcase3: ###### 7000000