1. 程式人生 > >python 輸入一個字符,是小寫轉換為大寫,大寫轉換為小寫,其他字符原樣輸出

python 輸入一個字符,是小寫轉換為大寫,大寫轉換為小寫,其他字符原樣輸出

style pre clas input span pan NPU pri code

 s = input(請輸入一個字符:)
 if a <= s <= z:
     print(chr(ord(s) - 32))
 elif A <= s <= Z:
     print(chr(ord(s) + 32))
 else:
   print(‘s‘)

python 輸入一個字符,是小寫轉換為大寫,大寫轉換為小寫,其他字符原樣輸出