example04.py 405 B

12345678910111213141516171819202122232425
  1. """
  2. example04 - 使用type函数检查变量的类型
  3. auther: tanlie
  4. date: 2026/8/20
  5. """
  6. a = 45
  7. b = 3.14
  8. c = "123.45"
  9. d = True
  10. print(type(a)) # <class 'int'>
  11. print(type(b)) # <class 'float'>
  12. print(type(c)) # <class 'str'>
  13. print(type(d)) # <class 'bool'>
  14. print(str(a)) # 45
  15. print(int(b)) # 3
  16. print(float(c)) # 123.45
  17. print(int(d)) # 1
  18. print(int(False)) # 0
  19. print(ord('檀')) # 27264
  20. print(chr(65)) # A