
TQC+ 程式語言Python 805 字串輸出
題目說明:
請撰寫一程式,要求使用者輸入一個長度為6的字串,將此字串分別置於10個欄位的寬度的左邊、中間和右邊,並顯示這三個結果,左右皆以直線 |(Vertical bar)作為邊界。
範例輸入
python
範例輸出
|python |
| python |
| python|
程式碼:
Str = input()
print('|%-10s|' %Str)
print('| %s |' %Str) # 或用 print('|%s|' %(Str.center(10))) 也可以。
print('|%10s|' %Str)
TQC+ 程式語言Python 第8類:字串(String)的運作
如果覺得文章內容還不錯的話,麻煩請幫我點個讚!感謝
可以多點幾次喔~~
第一次點讚需使用 Google 或 Facebook 帳號註冊

