Is there a standard way to check the type in Python?

Asked 2 years ago, Updated 2 years ago, 18 views

I want to know which object is which type What method is recommended when doing this?

For example, to determine if objecto is str.

python type

2022-09-22 14:10

1 Answers

type(o) is str

isinstance(o, str)

unicode string is not usbclass of str, so if you need to include it in this case,


2022-09-22 14:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.