Home  >  Q&A  >  body text

Python basics, data type issues

print type(-10)=="int"

Why does the above code return False?

type(-10) is integer data.

phpcn_u1582phpcn_u15822711 days ago847

reply all(2)I'll reply

  • 黄舟

    黄舟2017-05-18 10:48:27

    print(type(10) == int)
    True

    If you add double quotes to int, it becomes str, which is of course different from int.

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-18 10:48:27

    That’s not how it works. . .

    type(-10) is int
    isinstance(-10,int)

    reply
    0
  • Cancelreply