Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 18005

How do I change a string to a python type

$
0
0

If I have a string which is the same as a python data type and I would like to check if another variable is that type how would I do it? Example below.

dtype = 'str'x = 'hello'bool = type(x) == dtype

The above obviously returns False but I'd like to check that type('hello') is a string.


Viewing all articles
Browse latest Browse all 18005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>