网站开发工资怎么样,网站开发w亿玛酷1专注,长春专业企业网站建设价格,网络营销课程总结1500字Python#xff0c;由吉多范罗苏姆#xff08;Guido van Rossum#xff09;在1989打发圣诞节放假时间的一门“课余”编程项目#xff0c;至今已有二十多年的历史#xff0c;语法简洁清晰#xff0c;深受喜爱#xff1b; 小窥 # 查看版本
python -V # 输出
print he… Python由吉多·范罗苏姆Guido van Rossum在1989打发圣诞节放假时间的一门“课余”编程项目至今已有二十多年的历史语法简洁清晰深受喜爱 小窥 # 查看版本
python -V # 输出
print hello # 输入
str raw_input(press any key)
print str# 注释
print www.cnblogs.com # link # 帮助
dir(list)
help(list) 变量 # 无需声明和删除直接赋值type为内置函数查询类型
a 10
print a,type(a)
a “hello”
print a,type(a)
a “ word”
print a,type(a) 列表、元组和词典 #####
# 1. 列表list数据如同STL list下标从0开始支持添加删除
province [GuangDong, ZheJiang, HeNan, XinJang, HeiLongJiang]
print province[2]
province.append(‘HuBei’)
delete province[1]# 访问支持[下限上限步长]上限不包括在内
print province[:3] # idx from 0 to 7
print province[3:] # idx from 3 to end
print province[0:5:2] # from 0 to 4 with 2 steps
print province[3:0:-1] # from 2 to 1 with -1 steps
print province[-1] # the last one
print province[-3] # the second one from last #####
# 2. 元组Tuples如同list不过不能改变如12个月英文名之类的常量
days (Morning,Afternoon,Night)
print days,type(days)# 字符串是一种triple
str “Hello world”
print str[2:5]#####
# 3. 词典Dictionaries 如同hash, 元素结构为 key:value如成绩
stu_score {ZhangSan:34,LiSi:98, WangWu:99}# 新增key:value
str_score[LiLei] 100# 删除key
delete str_score[ZhangSan]# 检查
if str_score.has_key(‘HanMeiMei’):print “got HanMeimei ”
else print “not find HanMeiMei”# 打印所有keyvalues
print stu_score.keys(),str_score.values()
values stu_score.values()
values.sort()
print values,length(values) 循环 # Python中语句后无“”结尾无“”通过TAB4个空格
# 1. while
a 0
while (a 10)a a1;print a
# 2. if
y True
if y True:print “y is true”
elif y False:print “y is false”
else:print “value of y is error.”#3. For
tmp [1,’a’,’sdfa’,242]
for value in tmpprint value# 判断符号 , , , , , !, in 函数 # 定义函数show
def show(list, info)for entry in list:print entryreturn input(info) 1 # input输出数字
# 表传指针bulid-in传值
list [1,2,3]
info “press num: “
def show (list, info)list[1]3info “changed”
show(list, info)
print list,info 类 # 定义类
class Shapedef __int__(self, x, y): # 构造self.x xself.y ydef area():print self.x * self.y
shape Shape(100,20)
class Square(Shape) # 继承def __int__(self, x):self.x self.y x# 对象词典
class_dic {}
class_dic[“Shape”] Shape(100,20)
class_dic[“Square”] Square(100,20)
print class_dic[“Shape”].area
print class_dic[“Square”].area 模块 # 模块只定义集库比如变量、函数和类
# 可以自定义模块和模块包
import test_module
import dir.module # 相同类型放一个目录 文件操作 Ofile open(‘file’, ‘r’)
Ofile.seek(45,0)
# 支持seek、tell, readline, readlins, wirte, close 异常处理 try:a input(“press characters”)
except NameError:print “input a num” [Reference] http://zh.wikipedia.org/zh-cn/Pythonhttp://www.sthurlow.com/python/http://www.cnblogs.com/vamei/archive/2012/05/28/2521650.html转载于:https://www.cnblogs.com/sunjerdege/p/3387170.html