在函数中使用type()函数来检查参数的类型并进行比较。
示例代码:
def check_args(arg1, arg2):
if type(arg1) == type(arg2):
print("Arguments are of same type.")
else:
print("Arguments are of different types.")
check_args("hello", 5) # Output: Arguments are of different types.
check_args(10, 20) # Output: Arguments are of same type.
下一篇:比较创建时间和用户输入