说明:
在实际的应用过程中,有的时候可能会遇到字符串的10,需要将字符串的10转换为数字的10
在此记录下,通过int函数转换的过程。
操作过程:
将字符串转换为整型的10
>>> str1 = "10" #将一个字符串的10赋给变量str1
>>> type(str1)
<class 'str'> #通过type函数查出来类型是str
>>> int1 = int(str1) #通过int函数,转换为了int类型的10
>>> type(int1)
<class 'int'>
>>> int1
10