- python是一种解释语言,不需要编译,但是它的运行效率并不低,因为它产生的是一种近似机器语言的中间形式,是通过字节编译的。
- 查看python解释器的安装路径
import sys
print (sys.path)
3 输出方式和C语言相似
num = raw_input('please input a number:')
num = int(num)*2
print ('doubling your number:%d' %num)
这里要注意的是raw_input()方式输入的是字符串的形式,如果要进行数字运算还要进行数值类型的转换 ,输出结果为
please input a number:123
doubling your number:246
4.python的对大小写敏感
5.python是动态性语言,不需要事先定义变量,变量的类型和值在赋值的时候就被初始化。
6.python不支持自增和自减的操作,因为+-都是单目运算符,python 会这样解释:-(-n)=n
7.字符串的索引值:第一个下标为0,最后一个下标为-1,[:]指定下标
8.列表和元组的区别:
alist=[1,2,3,4,5,6]
print alist[0]
print alist[1:5]
alist[0]=100
print alist
print alist[:4]
运行结果:
1
[2, 3, 4, 5]
[100, 2, 3, 4, 5, 6]
[100, 2, 3, 4]
元组
atuple=(1,2,3,'hello',6,4,4)
print atuple[0]
print atuple[1:4]
atuple[0]=100
print atuple
运行结果
1
(2, 3, 'hello')
Traceback (most recent call last):
File "H:/������/study/test_1.py", line 11, in <module>
atuple[0]=100
TypeError: *'tuple' object does not support item assignment*
Process finished with exit code 1