[問題] 問一下format的用法
code :
for i in range(1, 5):
s = "{0:>" + str(i) + "}"
print(i, s, s.format("*") )
output :
1 {0:>1} *
2 {0:>2} *
3 {0:>3} *
4 {0:>4} *
問題 '*'前為何會有空白一直增加
網路上查到format的用法都是 像printf來格式化自己要的排版
上例中直接把字串format後面給符號不太清楚是什麼意思 希望有人能幫我解惑一下
另外 問一個vim的小問題
我用set noai來取消貼上自動縮排好像沒有 不知道為何
所以改用r!cat
然後貼上內容再ctrl+D就行了
但是r!cat是什麼意思呢
!後面加指令 來cat等待輸入我應該知道
但是r是我就不清楚了
以上,謝謝大家。
--
Talk is cheap. Show me the code. - Torvalds, Linus (2000-08-25).
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.67.180.162
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1500812462.A.B84.html
→
07/23 20:35, , 1F
07/23 20:35, 1F
→
07/23 20:37, , 2F
07/23 20:37, 2F
→
07/23 20:52, , 3F
07/23 20:52, 3F
→
07/23 20:57, , 4F
07/23 20:57, 4F

→
07/23 20:58, , 5F
07/23 20:58, 5F
→
07/23 20:59, , 6F
07/23 20:59, 6F
推
07/23 21:43, , 7F
07/23 21:43, 7F
→
07/23 21:44, , 8F
07/23 21:44, 8F
→
07/25 22:13, , 9F
07/25 22:13, 9F
→
07/25 22:14, , 10F
07/25 22:14, 10F