The first two days of contact with python: Understanding the variables and print

1 variables without defining the type, can be directly assigned

>>> a =5
>>> a
5

>>> a='hello'
>>> a
'hello'

 

2 variable type display type can be used directly

>>> type(a)
<class 'str'>

>>> a=4
>>> type(a)
<class 'int'>

 

3 print print values, which have '' or ''

>>> print(a)
4
>>> print('hello')
hello
>>> print("hello")
hello

Error demonstration:

>>> print(hello)
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
print(hello)
NameError: name 'hello' is not defined

 

Guess you like

Origin www.cnblogs.com/mayplestory/p/11978762.html