Re: [問題] 這問題提該怎解決

看板Python作者 (sating00)時間6年前 (2019/07/24 13:42), 6年前編輯推噓1(100)
留言1則, 1人參與, 6年前最新討論串3/3 (看更多)
看到這題之後想到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
太感謝了QQ
07/25 00:57, 1F
文章代碼(AID): #1TD--_JG (Python)
文章代碼(AID): #1TD--_JG (Python)