example05.py 383 B

123456789101112131415161718192021222324252627
  1. """
  2. example05 - 函数,
  3. author: tanlie
  4. date: 2026/8/22
  5. """
  6. def test(x: int, y: int) -> int:
  7. print("test()函数被调用了")
  8. return x + y
  9. test(1, 2)
  10. # test("a", 1) # 这里会报错,因为字符串和整数不能相加
  11. def test2(x: int, y: int) -> tuple:
  12. return x, y
  13. print(type(test(1, 2)))
  14. print(type(test2(1, 2)))
  15. a, b = test2(1, 2)
  16. print("a, b ->", a, b)