# -*- coding: cp936 -*- class Person: def setName(self,name): self.name=name
def getName(self): &nbs ......
# -*- coding: cp936 -*- x = 1 while x<=10: print("while---"+str(x)) x += 1 words = ['this','is','an','ex','parrot']
for word in words: & ......
# -*- coding: cp936 -*- #set集合 a = set([1,2,3]) b = set([2,3,4]) print(a|b)#a或b print(a&b)#a且b print(a-b)#a去除b print(a.difference(b))#等同上一个方法 print(a^b)#去除ab相同
print(a|b>b) print(a&b<b) ......
# -*- coding: cp936 -*- # def hello(name): return "Hello,"+name+"!" print(hello("zhangsan"))
#斐波那契数列 def fibs(num): result = [0,1] ......
# -*- coding: cp936 -*-
#序列 arrA = ['123',32] arrB = [123,'hel'] print("arrA length ="+str(len(arrA))) print(arrA[0]) arrC = [arrA,arrB] print(arrC)#序列合并
#字符串索引 str ="1234567" pr ......
# -*- coding: cp936 -*- # book = {"asd":123,"ds":321,"as":213} print(book) #dict创建字典 items=[('a',1),('b',2),('c',3)] print(dict(items)) print(dict(a=1,b=3)) #基本方法 print(l ......
# -*- coding: cp936 -*- #Python3.0中所有字符串都是unicode name = raw_input("input your name:")#input 用户需要输入"name" print("hello,"+name) raw_input("Press <enter>") ......
#! /usr/bin/python # -*- coding: utf8 -*- print("wlecome to python math")
#普通运算 a=2+2 b=4-2 c=2*3 d=4/2 e=9%2 f=2**3 print("2+2=%i" % a) print("4-2=%i" % b) print(" ......