Python变量赋值&类型转换

1、Python定义变量

1 name = cross10
2 print('name=',name)

打印结果:

name=cross10

2、Python变量赋值

Python通过input输入的参数默认为string类型

1 age = input('age=')
2 print('age type is:',type(age))

打印结果:

age=15

age type is: <class 'str'>

3、Python类型转换

1 age =int(input('age='))
2 print('age type is:',type(age))

打印结果:

age=15
age type is: <class 'int'>

posted @ 2018-01-22 22:05  cross10  阅读(1076)  评论(0编辑  收藏  举报