首页 > 编程语言 > 详细

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

时间:2019-12-03 19:58:37      阅读:70      评论:0      收藏:0      [点我收藏+]

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天:了解变量和打印

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!