第一个Python程序:
开始Python:
python
hello world:
>>> print 'hello, world'
hello, world
结束Python:
exit()
存储Python程序:
建立存储文件夹:
cd /home
mkdir ./python
cd ./代表当前目录,cd ..代表回到上级目录
建立python文件:
vim ./test.py
删除文件夹:
rm -rf 路径
删除文件:
rm -f 路径
运行python文件:
vim ./test.py
上传本地文件到服务器:
scp 本地目录 root@123.123.123.123:远程目录
Python基本语法:
1.Python大小写敏感
True、False
2.Python定义了一个特殊值None
None是一个特殊的空值
3.Python传递的是指针
b还是‘ABC’a = 'ABC'
b = a
a = 'XYZ'
4.常量用大写字母表示
PI = 3.141592653595.格式化
>>> 'Hi, %s, you have $%d.' % ('Michael', 1000000) 'Hi, Michael, you have $1000000.'
6.集合类型list
people = ['tom', 'jesse', 'jack']
len(people)
people[1]
people.append('mark')
people.insert(1,'anny')
people.pop(1)
people[1] = 'Tank'
some = ['abc', 123, True]
7.定义函数def
def new_abs(x): if not is instance(x,(int,float)): raise TypeError('wrong type') if x >= 0: return x else: return -x