正确例题 #!/usr/bin/python3
import time
t = time.localtime(time.time()) localtime = time.asctime(t) str = "当前时间:" + time.asctime(t)
print(str);
正确例题 for i in range (1,10): #两个循环知1-9 与 1-9相乘 for j in range(1,10): print(j,"x",i,"=",i*j,"\t",end="")#输出,道\t是输出后带tab空隔回,end="",表示不断行 if i==j: #该换行答了 print("") #输出空 break #换行
正确例题 str1 = 'abcdef' str2 = str1.replace('a','1').replace('b','2') print(str2)
正确例题 for i in range(1,10): for j in range(1,10): print("%s × %s = %s" % ( i ,j , i*j ))
正确例题 str1 = 'abcdef' print(str1)
正确例题 import re string="A1.45,b5,6.45,8.82" print (string)
正确例题 import re a = "aa,ab,ba,bb" b = a.replace("a","0").replace("b","1") print(b)
正确例题 import random import string z= ["a", "b", "c"] n=random.randint(0,len(z)) m=random.randint(0,len(z)) print(z[n],z[m])
正确例题 import random import string z= ["a", "b", "c"] n=random.randint(0,len(z)) print(z[n])
正确例题 import random s = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+=-" n=random.randint(0,len(s)) print(s[n])
正确例题 import random str1='this_a_string_with_several_characters' n=random.randint(0,len(str1)) print(str1[n])
正确例题 import random lst=[0,1,2,3,4,5,6,7,8,9] for i in range(5): a=random.choice(lst) lst.remove(a) print(a,lst)
正确例题 import random z=[0,1,2,3,4,5,6,7,8,9] a=random.choice(z) print(a)
正确例题 import random z= ["a", "b", "c"] a=random.choice(z) print(a)
正确例题 import random z= ["a", "b", "c"] a=random.choice(z) b=random.choice(z) print(a,b)
正确例题 import re m = ["a", "b", "c"] for i in range(0,3): for j in range(0,3): print("%s%s" % ( m[i],m[j]))
aa ab ac ba bb bc ca cb cc
[Process completed - press Enter]
正确例题 import re a="0" b="1" print(a+b)
m = ["a", "b", "c"] print(m)
正确例题 import re z = ["a", "b"] for i in range(0,2): for j in range(0,2): print("%s%s" % ( z[i],z[j]))
aa ab ba bb
[Process completed - press Enter]
正确例题 import re z = ["a", "b"] for i in range(0,2): for j in range(0,2): for k in range(0,2): print("%s%s%s" % ( z[i],z[j],z[k]))
aaa aab aba abb baa bab bba bbb
[Process completed - press Enter]
正确例题 import re z = ["a", "b", "c"] for i in range(0,3): for j in range(0,3): print("%s%s" % ( z[i],z[j]))
正确例题 import re z = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] for i in range(0,2): for j in range(0,2): print("%s%s" % ( z[i],z[j]))
00 01 10 11
[Process completed - press Enter]
正确例题 import re z = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] for i in range(0,2): for j in range(0,2): for k in range(0,2): print("%s%s%s" % ( z[i],z[j],z[k]))
000 001 010 011 100 101 110 111
[Process completed - press Enter]
正确例题 import re z = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] for i in range(0,3): for j in range(0,3): print("%s%s" % ( z[i],z[j]))
00 01 02 10 11 12 20 21 22
[Process completed - press Enter]