码迷,mamicode.com
首页 > 编程语言 > 详细

接触python的第2天:了解变量和打印

时间:2019-12-03 20:14:32      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:back   most   mod   not   rac   bsp   了解   erro   file   

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

 

接触python的第2天:了解变量和打印

标签:back   most   mod   not   rac   bsp   了解   erro   file   

原文地址:https://www.cnblogs.com/mayplestory/p/11978762.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!