接触python的第2天:了解变量和打印
1变量不用定义类型, 可以直接赋值
>>> a =5 >>> a 5 >>> a='hello' >>> a 'hello'
2 变量类型可以直接用type显示
>>> type(a) <class 'str'> >>> a=4 >>> type(a) <class 'int'>
3 print 可以打印数值,里面要有‘’ 或 “”
>>> print(a) 4 >>> print('hello') hello >>> print("hello") hello
错误示范:
>>> print(hello)
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
print(hello)
NameError: name 'hello' is not defined