#!/usr/bin/env python #-*-coding:utf-8-*- #print "hello,word"; #print 2 + 2 #print 1 / 2 #x = 3 #y = x *6 #print y #a = input("A1:") #b = input("B1:") #print a * b #a = "hello" #b = "word" #print a +','+ b #print('hello,\nworld') #print(r'hello,\nworld') #test = 'hello' #print test[0] #print test[-1] #print test[0:2] #print test[3:] #print test * 5 #字符串×5输出 #print ['jesse'] * 5 #print list(test) #打成字符串 #test = [22,11,33] #print len(test) #print max(test) #print min(test) #x = [1,2,3] #x[1] =8 #print x #del x[0] #删除一个位置的数据 #print x #test = list('hello') #test = [1,2,3] #test.append[4] #print test #print test #test[2:] = list('jesse') #在2的位置后面追加数据 #print test #test[1:3] = [] #把1-3位置的数据变成空 #print test #test = [1,2,3] #test = [] #print test #a = {1,2,3} #b = a.copy() #print b #b = a #b[1] = 4 #print a #输出1,4,3 #b = a.copy() #b[1] = 4 #print b #a = ['h','r','r','t','s','qw','w','h','h'].count('h') #print a #a = [1,2,3] #b = [4,5,6] #a.extend(b) #a = a+b #print a #a = ['a','b','v','tt'].index('v') #print a #输出a第一次出现的次数 #a = [1,2,3,4,5] #a.insert(3,'four') #print a #a.pop() #pop是删除最后一个元素 #print a #a = [1,2,3,4,5,6] #a.remove(2) #print a #删除指定位置的元素 #a.reverse() #print a #取反元素 #a = [99,2,32,23,43,1,3] #a.sort() #print a #按照顺序排列 #test = 'baidu.com' #te = test.find('co') #print te #seq = ['a','b','c','d'] #sep = '+' #test = sep.join(seq) #print test #输出a+b+c+d #a = 'HELLO,WORD' #b = a.lower() #print b #输出hello,word #b = a.replace('LL','oooooooooooo') #print b #a = '1+2+3+4+5+6'.split('+') #print a # 输出['1','2','3','4','5','6'] #a = ' hell,word ' #b = a.strip() #print b #去除字符串前后有的空格 #items = [('name','jesse'),('sex','1')] #a = dict(items) #print a #输出映射建名-对应 #print a['name']i #x,y,z=1,2,3 #print x,y,z #name = raw_input('my name is ?') #if name.endswith('jesse'): # print('hello,jesse') #else: # print('hello '+name) #number = int(raw_input('you has number?')) #if number > 90: # print "very good" #elif number > 60: # print "good" #elif number < 60: # print "No Pass" #x = 1 #while x < 100: # print x # x+=1 #jihe = ['hao','xiao','yu','han','shi','key'] #for jihes in jihe: # print jihes #exec("print('hello,word')") #fibs = [0,1] #for i in range(8): # fibs.append(fibs[-2]+fibs[-1]) #print fibs #自定义函数 #def hello(name): # return 'hello,'+name+'!' #print(hello(' jesse')) #def add(a,b): # return a+b #print(add(8,9))
#!/usr/bin/env python #-*-coding:utf-8-*- #class Class: # def add(self): # print('I have a self') #def function(): # print('my name is haoxiaoyu') #instance = Class() #instance.add() #instance.add = function #instance.add() # def hello(): print("hello,word") root@pc:/home/jesse/tmp/python# cat 2.py #!/usr/bin/env python #-*-coding:utf-8-*- #class Class: # def add(self): # print('I have a self') #def function(): # print('my name is haoxiaoyu') #instance = Class() #instance.add() #instance.add = function #instance.add() # def hello(): print("hello,word")