最近需要学Python写代码了,打算写个简易的学习笔记...^_^
学习任何语言自然要从Hello World开始啦
root:~ root$ Python
Python 2.7.10 (default, Feb 6 2017, 23:53:20)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> print "hello world"
hello world
>>> exit()
root:~ root$ python hello.py
hello world
roots:~ root$ cat hello.py
#!/usr/bin/python
print 'hello world'
接着看数据类型:
>>> a = 10
>>>
>>> print (a)
10
>>> print (type(a))
>>> a = 5.4
>>>
>>> print (a,type(a))
(5.4, )
>>>
>>> a = 10
>>> a = False
>>> a = 3.2
>>> a = 'Hello World'
type查看数据类型,其它就是整数、字符串、浮点数等等啦
阅读(1773) | 评论(0) | 转发(0) |