作者sating00 (sating00)
看板Python
标题Re: [问题] 这问题提该怎解决
时间Wed Jul 24 13:41:56 2019
看到这题之後想到Python其实有对其的功能,详细转贴网路上找到的教学:
https://blog.jaycetyle.com/2018/01/python-format-string/
以下为刚刚打的程式码:
====
list1=[i for i in range(1,10)]
f=""
for o in list1:
f=str(o)+f
print("{0:>9}".format(f))
====
1. list1的地方为将1~9做成一个list
2. 做一个空的str => f
3. 把str後的o跟f在每一次for回圈中相加
4. "重点" 把f对其右方(利用">"符号),总共格数是"9"格
result:
====
https://imgur.com/rzUdGj6.jpg
====
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 61.223.238.201 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1563946943.A.4D0.html
※ 编辑: sating00 (61.223.238.201 台湾), 07/24/2019 13:43:46
1F:推 spong: 太感谢了QQ 07/25 00:57