写出func函数的三个重载函数value of x is 7 value of x is 9.132 value of x and y is 85,64
时间: 2024-04-29 18:22:13 浏览: 88
9个必须知道的实用PHP函数和功能
下面是三个重载函数的代码示例:
```python
def func(x: int) -> None:
print(f"value of x is {x}")
def func(x: float) -> None:
print(f"value of x is {x:.3f}")
def func(x: int, y: int) -> None:
print(f"value of x and y is {x},{y}")
```
调用这些函数的方法如下:
```python
func(7)
func(9.132)
func(85, 64)
```
输出结果分别为:
```
value of x is 7
value of x is 9.132
value of x and y is 85,64
```
阅读全文