1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
| #!/usr/bin/python # -*- coding: UTF-8 -*-
#num1 = input("Pls input a number: ") #num2 = input("Pls input a number: ")
#print "%s + %s = %s" % (num1, num2, num1+num2) #print "%s - %s = %s" % (num1, num2, num1-num2) #print "%s * %s = %s" % (num1, num2, num1*num2) #print "%s / %s = %s" % (num1, num2, num1/num2)
#var = 101 #if ( var == 100 ) : print "变量 var 的值为100" #print "Good bye!"
#x = int(raw_input("pls input a number: ")) #y = int(raw_input("pls input a number: ")) #z = int(raw_input("pls input a number: "))
#aa = [x,y,z] #list(aa)
#aa.sort() #print aa
#for i in xrange(10): # if i == 5: #print "id:%s" %i #continue ##当i==3的时候就会跳出此次循环,也就是下面的程序不会再次执行。 # if i == 4: ##当i ==5的时候就直接跳出整个循环。 # break # print i #else: # print "main end"
#import time #插入一个time对象(一切皆对象,) #import sys #插入一个sys对象
#for i in xrange(10): # if i == 3: # continue # elif i == 5: # continue # elif i == 6: # sys.exit() ## 当i==6的时候主动退出整个脚本。 # print i #else: # print "main end"
#import random #import sys
#bb = random.randint(1,20) #print bb #for i in xrange(1,7): # aa = int(raw_input("pls input a number: ")) # if aa == bb: # print "you're so smart!!" # sys.exit() # elif aa > bb: # print "pls input a small number." # else: # print "pls input a big number." #else: # print "time is end!"
#for i in xrange(1,10): # for j in xrange(1,i+1): # print "%sx%s=%s" % (j, i, j*i), ## ,的原因是不让程序自动换行 # print
#count=0 #for i in '1234': # for j in '1234': # for m in '1234': # if (i != j) and (j != m) and (i != m): # print "%s %s %s" % (i, j, m) #count+=1 #print #print count
#for i in xrange(100,1000): # unit = i % 10 # ten = i // 10 % 10 # hundred = i // 100 # if unit ** 3 + ten ** 3 + hundred ** 3 == i: # print(i)
#for a in 'xyz': # for b in 'xyz': # for c in 'xyz': # if a != b and b != c and c != a: # if a != 'x' and c != 'x' and c != 'z': # print "a vs %s b vs %s c vs %s" % (a, b, c)
#list1 = ['x','y','z'] #for a in list1: # a 从 xyz中挑一个对手 # for b in list1: # b 挑一个对手 # if a != b: # a的对手和b的对手不相同 # for c in list1: # c挑一个对手 # if a != c and b != c: # a,b,c,对手互不相同 # if a != 'x' and c != 'x' and c != 'z': # a的对手不是x,c的对手不是x,c的对手不是z # print "a-{0} b-{1} c-{2}".format(a, b, c) # 打印出结果
#aa = open('/root/study/python/vm.ini') #for line in aa: # print line,
#aa = open('/root/study/python/vm.ini') #while True: #line=aa.readline() #if not line: #break #print line,
#with open('/proc/meminfo') as aa: # for line in aa: # if line.startswith('MemTotal'): # MemTotal = line.split()[1] # continue # if line.startswith('MemFree'): # MemFree = line.split()[1] # break # print "The Memory Total: {:.2f}".format(int(MemTotal)/1024.0) + 'M' # print "The Memory left: {:.2f}".format(int(MemFree)/1024.0) + 'M' # print "The Memory left percent: {:.2f}".format((int(MemFree)/1024.0)/(int(MemTotal)/1024.0)*100) + '%'
#mac = '00:0c:29:9c:dc:41' ##本地电脑的Mac地址 #mac_prefix = mac[:-3] ##取出Mac地址的前缀 #last_two = mac[-2:] ##取出MAC地址的后三位 #plus_one = int(last_two, 16) + 1 ##把16进制的mac转换成10进制并+1 #new_last_two = hex(plus_one)[-2:] ##再次把10进制的mac地址转换成原来的16进制,如果不加[-2:],则会出现 0x的前缀 #new_mac = mac_prefix + ':' + new_last_two ##把刚刚整理好的前缀和新的后两位拼接起来。 #print new_mac
#import codecs
''' /etc/passwd 查找用户,对用户优先级进行排序 ''' #3with codecs.open("passwd", "r") as f: # result = sorted(f.readlines(), key=lambda x: int(x.split(':')[2])) # print result #with codecs.open("sortPasswd", "w") as f: # f.writelines(result)
#def Jianjia(x): # y =0.5 # x = x * y # return x #print(Jianjia(100)) #print(Jianjia(50))
|