python学习笔记一

来源:互联网 发布:js body append html 编辑:程序博客网 时间:2024/05/16 09:30

1. input()默认是str类型,如果进行计算,需要手动转换成int型数据

>>> x =input('x:=')x:=4>>> y =input('y:=')y:=4>>> print(x*y)Traceback (most recent call last):  File "<pyshell#3>", line 1, in <module>    print(x*y)TypeError: can't multiply sequence by non-int of type 'str'>>> print(int(x)*int(y))16>>>


0 0
原创粉丝点击