variable assign
#one lin comment """ multi line comment """ #variable assign x = 1 print x x += 1 print x x,y = 1,2 print x,y x = 1.999 print x string = "this is stirng" print string
list:
mlist = [12,45,1] mlist.append(3) print mlist mlist.append(1) print mlist print mlist.count(1),mlist.index(1) print mlist print mlist.reverse() mlist.remove(1) print mlist print mlist.pop(2) mlist.append(11);
dictionary
#dictionary
info = {'name': 'lewis'}
print info
info['title']= 'member'
info['age']= '23'
info['locate']= 'taipei'
print info
print info.keys()
print info.get('name')
del info['locate']
print info
#set
channel = set()
channel.add('ylib')
channel.add('zinio')
channel.add('ibobar')
tChannel = {'ibobar','ylib'}
print channel & tChannel
print channel | tChannel
print channel ^ tChannel
print channel - tChannel
print channel - tChannel
print channel | tChannel
String
#String x = 'i\'m lewis' print x y = ',hi1234' z=x+y print z print z[-3] print z[3:-2] print z[3:1] print len(z) ss='123' for s in ss: print (s , ':') print z*2 print y in z
#type convertion i = 10 d = 1.5 f = 3.5 s = "string" c = 'c' print int(i+d) print float(10/2.6) print i%d print ord(c)+10 print chr(ord(c)+i)





沒有留言:
張貼留言