Re: [問題] 這問題提該怎解決
看到這題之後想到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://www.ptt.cc/bbs/Python/M.1563946943.A.4D0.html
※ 編輯: sating00 (61.223.238.201 臺灣), 07/24/2019 13:43:46
推
07/25 00:57,
6年前
, 1F
07/25 00:57, 1F
討論串 (同標題文章)
完整討論串 (本文為第 3 之 3 篇):
Python 近期熱門文章
PTT數位生活區 即時熱門文章