首页 > 编程语言 >一些python练习

一些python练习

时间:2022-10-14 21:33:10浏览次数:66  
标签:10 set python 练习 list range input print 一些

# a = 22  # a的值不为零所以bool为真 # b = 11 # print(a and b) # print(a or b)   # a 和 b中有一个真就全真 # print(not a)    # not取反,a为假 # print(not b)
# 某公司奖金计算 # j = 0 # i = float(input("你的工资:")) # if  i > 100: #     j = (i -100) * 0.01 +  10 * 0.1 + 10 * 0.75 + 20 * 0.03  + 20 * 0.015 # elif  (i > 60) and (i <= 100): #     j = (i - 60) * 0.015 + 10 *0.1 + 10 * 0.75 + 20 * 0.05 + 20 * 0.03 # elif  (i > 40) and (i <= 60): #     j = (i - 40) * 0.03 + 10 *0.1 + 10 *0.75 + 20 * 0.05 # elif  (i > 20) and (i <= 40): #     j = (i - 20) * 0.05 + 10 * 0.1 + 10 *0.75 # elif (i > 10) and (i <= 20) : #     j = (i - 10) * 0.75 + 10 * 0.1 # elif i <= 10: #     j = i * 0.1 # print('你的奖金',j,"万")
# i = 1 # while i <= 50: #     if i % 2 ==0: #         print(i * i,end =" ") #     i += 1
# i = 0 # while i < 50: #     print(i , ) #     i += 1 # else: #     print(i , "is not less than " )
# str_1 = "hkolp" # for i in str_1: #     print(i)
# lit = ["jcbj", "bnkkn", "jfiji"] # for i in lit: #     print(i, end =" ")
# 水仙花数 # for i in range(100, 1000): #     g = i % 10  #个位 #     s = i // 10 % 10 #十位 #     b = i // 100  #百位 #     if (g**3 + s**3 + b**3) == i: #         print("水仙花: ",i) # else: #     print('查找完成')
# a = [1, 4, 9, 14, 21] # for i in range(len(a)): #len是长度 #     if i % 2 == 0: #         print("当前数字:", a[i])
# 成绩判定 # fen = int(input("请输入0---100的数: ")) # 接收一个数 # if 89 <= fen < 100:  # 判断分数 #     print(" 优秀 ") # elif 70 <= fen < 89: #     print(" 良好 ") # elif 60 <= fen < 70: #     print(" 一般 ") # elif 0 < fen <60: #     print("不及格!!") # else: #     print("请安要求输入!")
# # 鸡兔同笼 # for i in range(16, 32): #     for j in range(32): #         if (4 * i + j * 2) == 64 and (j >= 14): #             print("兔兔的数量:",i,"小鸡的数量:",j)
# # 求公倍数问题 # for i in range(1, 100): #     if (i % 7 == 0) and (i % 5 == 0): # 用取余判断是否整除 #         print("公倍数为:", i)
# 猜数字 # import random  #导入random模块 # answer = random.randint(0, 100)  #用randint给定一个范围 # count = 0 # while True: #     count += 1 #     number = int(input("请输入一个数字:")) #     if number > answer: #         print("大了,游戏继续进行") #     elif number < answer: #         print("小了,游戏继续进行") #     else: #         print("恭喜你答对了!") #         break
# #计算地铁费用 # z = int(input("请输入要搭乘的站数: ")) # p = int(input("请输入人数:")) # m = 0     #总车费 # if  1 <= z <= 4:   #判断站数确定单价 #     m = p * 3 #     print("总车费 :",m) # elif 5 <= z <= 9: #     m = p * 4 #     print("总车费 :",m) # elif z > 9: #     m = p * 5 #     print("总车费 :",m) # else: #     print("输入错误!")
# #分数换成等级制度 # f = float(input("请输入你的分数:")) # if 100 >= f > 90:       #根据等级划分区间 #     print("恭喜你得了A") # elif  80 < f <= 90: #     print("恭喜你得了B") # elif  70 < f <= 80: #     print("恭喜你得了C") # elif  60 < f <= 70: #     print("很遗憾你得了B") # elif  0 <= f <= 60: #     print("再见了你得了D") # else: #     print("输入错误!")
# #象限判断 # x = int(input("请输入x轴: ")) # y = int(input("请输入y轴: ")) # if x > 0: #     if y == 0: #         print("在x轴上 ") #     elif y > 0: #         print("在第一象限 ") #     elif y < 0: #         print("在第四象限") # elif y < 0: #     if x == 0: #         print("在y轴上 ") #     elif x < 0: #         print("在第三象限") # elif  x < 0: #     if y == 0: #         print("在x轴上") #     elif y < 0: #         print("在第三象限") #     elif y > 0: #         print("在第二象限") # elif  x == 0: #     if y > 0 or y < 0: #         print("在y轴上") #     elif y == 0: #         print("原点") # else: #     print("在原点")
# 身份验证 # i = 3 # while i > 0: #     i -= 1 #     x = input("用户名:") #     y = input("  密码:") #     if x == "admin" and y == "root": #         print("欢迎登陆!") #         break #     else: #         print("用户名或密码错误!请重新输入!") #         print("你还有 ",i," 机会")
# 奇数和问题 # n = int(input("请输入一个整数:")) # sum = 0  #存奇数和 # while n > 0: #     if n % 2 != 0: #         sum = sum + n #     n = n - 1 # print("奇数和为: ",sum)    
# #倍数问题 # m = int(input("请输入一个整数:")) # sum = 0 # while m > 0: #     if (m % 3 == 0) and (m % 6 !=0): #         sum = m + sum #     m = m -1 # print("最后结果:",sum)
# #字符串中字符输出 # c = input("请输入一个字符串:") # for i in c: #     print(i)
# #最大公约数和最小公倍数 # m = int(input("第一个整数:")) # n = int(input("第二个整数:")) # count = 0 # n1 = 0 # n2 = 0 # if m >= n:   # 最大公约数的判断 #     for i in range(1, n + 1): #         if (m % i == 0) and (n % i == 0): #             if n1 <= i: #                 n1 = i #     for j in range(m, m * n + 1):  # 最小公倍数的判断 #         if (j % n == 0) and (j % m == 0): #                 n2 = j #                 break # elif m <= n:                       # 最大公约数的判断 #     for i in range(1, m + 1): #         if (m % i == 0) and (n % i == 0): #             if n1 <= i: #                 n1 = i # for j in range(n, m * n + 1):       # 最小公倍数的判断 #         if (j % n == 0) and (j % m == 0): #                 n2 = j #                 break # print('最大公约数:', n1) # print("最小公倍数:", n2)
# # 求最大公约数 # m = int(input("请输入一个整数:")) # n = int(input("请输入另一个整数:")) # while True: #     if m == n: #         break #     elif m > n: #         m =  m - n #     elif m < n: #         n = n - m # print("最大公约数", n)         # list = [1, 2, 3, 4, 5] # for i in range(0, len(list)): #     print(list[i])
# list = [1, 2, 3, 4, 5] # for i in range(0, 5): #     print(list[i])
# count = 0 # a = ['alex', 'bob', 'lucy', 'lily'] # b = ['语文', '数学', '英语'] # for i in range(0, len(a)): #     for j in range(0, len(b)): #         print(a[i], b[j]) #         count += 1 # print(count) # count1 = 0 # a = ['alex', 'bob', 'lucy', 'lily'] # b = ['语文', '数学', '英语'] # for i in a: #     for j in b: #         print(i, j) #         count1 += 1 # print(count1)
# for i in 'Python': #     if i == 'h': #         break #     print(i)
# for i in range(1, 10): #     # if i ==1: #     #     break #     for j in range(2, 11): #         if i == 1: #             break #         else: #             print(i,j)
# m = 0 # n = 0 # c = 0 # ch_1 = input("输入字母:") # for i in ch_1: #     if i < 'z': #         n = ord(i) + 1 #         m = chr(n) #         print(m,end='') #     else: #         c = 'a' #         print(c,  end="")
# 两个骰子 # a = [1, 2, 3, 4, 5, 6] # b = [1, 2, 3, 4, 5, 6] # for i in a: #     for j in b: #         print("可能的情况:",i,j)
# z = 0  #三位数 # for i in range(1, 10):   #百位范围 #     for n in range(0, 10):  #十位范围 #          for j in range(1, 10):  #个位范围 #             if (i < j)  and (n > j): #                 z = i * 100 + j + n * 10 #                 print('数字',z,'符合要求')
# #数字判断2 # for i in range(1, 10):  #十位 #     for j in range(0, 10):  #个位 #         if (i + j) == 5:  #终止条件 #             break #         print(i *10 + j)
# 数字判断3 # s = 0 # for i in range(1, 6):         # 十位 #     for j in range(0, 10):    # 个位 #         s = i * 10 + j #         if s % 5==0: #             continue #         print(s)  
# import random  #导入随机数模块 # number = random.randint(0, 100)  #用randint设置一个范围 # print("随机数已生成....游戏开始 ") # i = 6          #设置初始值 # while i > 1: #     i -= 1     #结束条件 #     print("还剩",i,"次机会请猜数:",end='') #     test_1 = int(input()) #     if test_1 > number:       #做出艰难的判断 #         print("比随机数大") #     elif test_1 < number: #         print("比随机数小") #     else: #         print("恭喜你猜对了!")
# # 鸡兔同笼 # for i in range(1, 35):  #最多兔子时 #     for j in range(1, 35):  #最多鸡时 #         if (4 * i + j * 2) == 94: #             print("兔兔的数量:",i,"小鸡的数量:",j)
# # # 水仙花数 # for i in range(100, 1000):  #给定一个范围 #     g = i % 10  #个位 #     s = i // 10 % 10 #十位 #     b = i // 100  #百位 #     if (g**3 + s**3 + b**3) == i:  #水仙花数 #         print("水仙花: ", i) # else: #     print()
# def fac(n): #     if n == 1: #         return 1 #     else: #         return fac(n-1) # print(fac(6))
# def word(h): #     if h == 1: #         l = 0 #         l = l-1 #         print(words[l]) #         return 1 #     else: #         return word(h - 1) # words = input('shu:  ') # h = len(words) # word(h)

# lis_t1 = ['aa', 'bb', 1, 3, None ] # list2 = [ 1, 2, 3, 4, 5, 6, 7] # for i in range(7): #     if ((list2[i] + 1)  % 2) == 0: #         print(list2[i]) #     else: # #         pass # list_A = [-17, 29, 18, 29, 16] # max = 0 # for j in range(5): #     if list_A[j] > max: #         max = list_A[j] #     else: #         pass # print(max)
# a = ['a', 'b', 'd', 3, 7] # a[2] = '3' # a.append(9) # print(a)
# list_scorp = [92, 87, 79, 96, 53, 71] # list_scorp1 = [] # for x in list_scorp: #     if x < 80: #         list_scorp1.append(x) #     else: #         pass # print(list_scorp1)
# list_scorp = [92, 87, 79, 96, 53, 71] # del list_scorp[1] # print(list_scorp) # del list_scorp # print(list_scorp)
# # 算平均值,去掉一个最大和一个最小 # import random                                            # 导入随机数模块 # list_score = [27.89, 22.79, 21.37, 39.83, 25.97, 13.66]  # 定义一个列表 # number = random.choice(list_score)                       # 用choice指定列表的一个值 # list_score1 = []                                         # 准备一个容器 # max = 0                                                  # 设置初始值 # min = number                                             # 将列表的随机一个赋值给min # n = 0 # m = 0 # sum = 0 # for i in range(len(list_score) - 1):                     # 目的是找出最大值索引 #     if max < list_score[i]: #         max = list_score[i] #         m = i #         print(m) #     if min <= list_score[i]:                             # 当min的初始值为最小时让n得到索引 #             n = i #             print(list_score) # del list_score[m] # del list_score[n + 1]                                    # 前面删了一个需要加上删去的那个值,保证索引不移位 # for count in list_score:                                 # 计算出列表的总分数 #     sum += count # p = sum / len(list_score)                                # 求平均值 # print("%.2f" % p)
# my_name ="leenas" # my_age = 19 # my_height = 200 # my_weight = 100 # my_eyes = 'brown' # my_teeth = 'red' # my_hair = 'black' # print(f'lets talk about {my_name}') # print(f"he's {my_hair} inches tall") # print(f"he's {my_weight} pounds heavy.") # print("Actually that's not too heavy")
# 定义一个列表 # list_a = [] # list_b = ['1', 2, 3, 4.13, None] # print(list_b)
# # 访问列表元素 # list_c = ['python', 'love', 'alex', 1, 3, 6] # print(list_c[2]) # print(list_c[1: 3])
# # 更新列表元素 # list_d = [1, 3, 5, 7, 9] # list_d.append(11) # print(list_d) # list_d[3] = 'luky' # print(list_d[3])
# # 删除列表 # list_e = [ 1, 2, 2, 6, 3, 8, 5] # del list_e[2] # print(list_e) # list_e.remove(6)  # 删除列表中指定值 # print(list_e) # del list_e # print(list_e)
# # 列表的综合运用 # new_list_f = [] # list_f = [ 1, 3, 3, 5, 9, 2, 1] # for i in list_f: #     if i % 2 != 0: #         new_list_f.append( i * i ) #     else: #         print("生成列表完毕!") # print('新列表为:',new_list_f)
# # 获取列表中重复数(问题还有点大) # # 方法一 # dock = 0 # list2=[]     # list1 = [3,1,3,7,3,3] # for i in set(list1): #     count=0 #     for j  in range(len(list1)): #         if i==list1[j]: #             count +=1 #     print(i,count)
# # 方法二 用count方法统计 # list1 = [ 1, 1, 3, 3, 3, 7] # c = 0 # for i in range(len(list1)):  # 给出索引 #     c = list1.count(list1[i])  # 存次数 #     print(list1[i],c)
# 切片 # list_a = [1, 2, 3, 4, 5] # list_a[:] # print(list_a) # print(list_a[-1:])  #切片方向不变 # print(list_a[-2:])
# list_A = [ 2, '9', 17, 13] # print(list_A[1:])   #取出后三个 # print(list_A[-3:]) # print(list_A[2:])   # 取出[17,13] # print(list_A[-2:]) # print(list_A[-3:-1]) # print(list_A[1:3])
# l = list(range(10))   # 定义一个列表 # print(l[:3]) # print(l[-3:]) # print(l[2::2])   # print(l[::3]) # print(l[:]) # print(l[::-1])  # 倒叙 # print(l[::-2]) # print(l[:100]) # 不会改变默认长度
# list_B = 'python heloo' # print(list_B[:7]) # 包括空格
# [3 * i + 5 for i in range(1, 16)] # # print([3 * i +5 for i in range(1, 16)]) # print([x * x for x in range(1, 10) if x % 2 != 0])
# # 列表制造 # print([x + y for x in range(1, 11) if x % 2 != 0 for y in range(1, 11) if y % 2 == 0]) # print([x * y for x in range(1, 11) if x % 2 != 0 for y in range(1, 11) if y % 2 == 0])
# P = 3.14 # print([ P * x  ** 2  for x in range(1, 10) if x % 2 != 0]) # 奇数圆面积
# count = 0 # i = int(input('请输入一个截止范围:')) # L = [ x for x in range(i) for y in range(i + 1) if x // y == 0 count += 1  and if  count == 2] # print(L)
# 待做。。。 # count = 0 # i = int(input("shuru: ")) # for x in range(1, i + 1): #     for y in range(1, i + 1): #         if x // y == 1 or x % y == 0: #             count += 1 #         if count == 2: #             print(x) #             count = 0 #             continue         # i = 2 # j = 1 # while i <= 20: #     while j <= i: #         if i % j == 0: #             print(i) #         i = 1 + i #         j = 1 + j
# !!!def f(n): #     if n == 1: #         return 1 #     else : #         return n * f (n -1)
# print(f(5))
# # #  期中第一题 # tag = 'fglaa7gf:a{bwrioe5i71q1wc9xuo17bmhjret5}2' # print(tag) # tag_1 = [] # tag_x = tag[:8]                 # 先分片 # for i in range(len(tag_x)): #     if i % 2 == 0:              # 取偶数发现刚好有flag #         tag_1.append(tag[i]) # print(tag_1) # for i in range(8, len(tag)): #     if i % 4 == 0:              # 发现能被四整出的组合出welcome #         tag_1.append(tag[i]) # for i in tag_1: #     print(i, end='')
# # # 第二题 # list_1 = [] # for i in range(5): #     shu = int(input("请随机输入五个数:")) #     list_1.append(shu) # print(list_1) # list_2 = [] # flag = 0 # count = 0 # for i in range(len(list_1) - 1): #     for j in range(i + 1, len(list_1)): #         if list_1[i] >= list_1[j]: #             flag = list_1[i] #             list_1[i] = list_1[j] #             list_1[j] = flag #             count += 1 #         else: #             pass #     list_2.append(list_1[i]) # list_2.append(list_1[i]) # print('中位数', list_2[2])
# # 第三题 # list_1 = [1, 32, 28, 43, 48, 33, 6, 10, 27, 1, 48, 19, 25, 15, 17, 23] # print(list_1[7: 14][::-1]) # list_2 = [] # list_3 = [10] # for i in range(len(list_1)): #     if i % 2 == 0: #         list_2.append(list_1[i]) # print(tuple(list_2)) # for i in range(len(list_1)): #     if i % 3 == 0: #         list_1.insert(i, 10) # print(tuple(list_1))
# # 第四题 # x = 0 # c = 0 # dz = 0 # moy = int(input("输入消费金额:")) # if moy > 0: #     x = input("是否充值 ?输入 y or n") #     if x == 'y': #         c = int(input("输入充值:")) #         if 0 < moy <= 500: #             dz = 3 #             print('消费等级lv1,优费3元,余额:%f' % (c - moy + dz)) #         elif 500 < moy <= 2000: #             dz = 112 #             print('消费等级lv2,优费112元,余额:%f' % (c - moy + dz)) #         elif 2000 < moy: #             dz = 256 #             print('消费等级lv3,优费256元,余额:%f' % (c - moy + dz)) #     if x == 'n': #         if 0 < moy <= 500: #             dz = 3 #             print('消费等级lv1,优费3元') #         elif 500 < moy <= 2000: #             dz = 112 #             print('消费等级lv2,优费112元') #         elif 2000 < moy: #             dz = 256 #             print('消费等级lv3,优费256元')
# # 第五题 # list_a = [-3, 10, -8, 1, 20, 0, 8, -4, 9] # list_b = [-2, 0, 3, 3, 18, 9, 15, 4, -3, 2, 6, 13, 17, 11] # list_end = [] # # list_a.sort()     # 不用sort # # print(list_a) # # list_b.sort(reverse=True) # # print(list_b) # # list_a.extend(list_b) # # list_a.sort(reverse=True) # # print(list_a) # flag = 0 # for i in range(len(list_a) - 1):        # 升序 #     for j in range(i + 1, len(list_a)): #         if list_a[i] > list_a[j]: #             flag = list_a[i] #             list_a[i] = list_a[j] #             list_a[j] = flag # print(list_a) # for i in range(len(list_b) - 1):        # 降序 #     for j in range(i + 1, len(list_b)): #         if list_b[i] < list_b[j]: #             flag = list_b[j] #             list_b[j] = list_b[i] #             list_b[i] = flag # print(list_b) # list_end.extend(list_a) # list_end.extend(list_b) # for i in range(len(list_end) - 1):      # 组合降序 #     for j in range(i + 1, len(list_end)): #         if list_end[i] < list_end[j]: #             flag = list_end[j] #             list_end[j] = list_end[i] #             list_end[i] = flag # print(list_end)
# # 或许是代码错啦,或许是效率太低(完全数) # for z in range(1, 10000): #     count = 0 #     Nu = z #     for i in range(1, Nu): #         for j in range(Nu, 0, -1): #             if i * j == Nu and i < j and count <= Nu: #                 if j == Nu: #                     j = 0 #                 count = count + i + j #     if count == Nu: #         print(count)
# 完全数 # list1 = [] # for i in range(2, 10000): #     sum = 0 #     for y in range(1, i): #         if i % y == 0:       # 因数整除 #             sum += y         # 因数累加 #     if i == sum:             # 判断完全数 #         list1.append(sum)    # 存数 # for i in list1: #     print(i, end=',')
# lis_t = [5, 4, 9, 7, 1, 6] # flag = 0 # for i in range(len(lis_t) - 1): #     for j in range(i + 1, len(lis_t)): #         if lis_t[i] > lis_t[j]: #             flag = lis_t[i] #             lis_t[i] = lis_t[j] #             lis_t[j] = flag # print(lis_t)
# a = {} # for i in range(10): #     a.add(i) # print(a)
# a = {} # b = set() # print(a, b)
# c = ['hello', 'name', 'alex', 'job'] # a = set(c)             # 列表转集合 # set_c = {1, 3, 4} # print(a)
# set_str = "helloword" # print(set(set_str)) # set_g = {1, 2, 3, 3, 3, 33, } # # print(set_g[1])
# list_a = {1, 2, 3, 4, 5} # list_b = {1, 2, 5} # print(list_a - list_b)          # 差集 # print(list_a.difference(list_b)) # print(list_b - list_a) # print(list_b.difference(list_a)) # print(list_a | list_b)          # 并集 # print(list_a.union(list_b)) # print(list_a & list_b)          # 交集 # print(list_a.intersection(list_b)) # print(list_a ^ list_b)          # 并集 —— 交集 # print(list_a.symmetric_difference(list_b)) # print(list_a < list_b) # print(list_a.issubset(list_b)) # print(list_a > list_b) # print(list_b.issubset(list_a)) # list_b.add(4) # print(list_b) # list_b.add([4, 5]) # print(list_b) # list_b.update([8, 9]) # c = (4, 5) # set_1 = {1, 2, 3} # set_1.add(c) # print(set_1) # set_1.update([7, 8]) # print(set_1) # set_1.remove(7)     # 删除集合中的值 # print(set_1) # set_1.discard(9)   # 删除值列表不存在时不报错 # print(set_1) # # c = ["hello", "name", "alex", "job"] # a = set(c)          # 将列表转换成集合 # set_c = {1, 3, 4}      # 定义一个列表 # set_str = "hello word"      # 字符串转换成集合 # print(set(set_str)) # a = {}      # 空字典 # b = set()   # 空集合 # set_c.add(4)    # 集合中添加4 # print(set_c) # set_c.update([6, 9])    # 集合中添加多个元素 # print(set_c) # # set_c.remove(15)        # 删除列表存在的,不存在时会报错 # set_c.discard(15)       # 查找列表中存在的删除,不存在时不报错
# set_a = {1, 2, 4, 5} # set_b = {1, 2, 5} # print(set_a - set_b)    # 输出a和b的差集 # print(set_a.difference(set_b))  # 输出a和b的差集 # print(set_b - set_a)        # 输出b与a的差集 # print(set_b.difference(set_a))  # 输出b与a的差集
# import random # list_static = [] # for x in range(0, 1001): #     number = random.randint(1, 1000) #     list_static.append(number) # flag = 0 # for i in range(len(list_static) - 1): #     for j in range(i + 1, len(list_static)): #         if list_static[i] > list_static[j]:             # 前一个与后一个比较,交换位置 #             flag = list_static[i] #             list_static[i] = list_static[j] #             list_static[j] = flag # print(list_static) # print(set(list_static))             # 集合去重复值
# import re   # 引入正则表达式 # str_orgin = "BAAABAB" # str_orgin = "ip是:192.168.71.12" # re_string = r"\d.*" # re_string = r"BA(.*)BA(.*)"     # 分组group() # str_orgin = "BAAABAB" # re_string = r"AB"                           # AB为一个字符组 # print(re.findall(re_string, str_orgin))     # .findall用于获取所有的字符组以列表还回 # re_pattern = re.compile(re_string) # # if re.search(re_pattern,str_orgin) != None: #     print(re.search(re_pattern, str_orgin).group()) #     # print(re.search(re_pattern, str_orgin).group(2)) # else: #     print("未匹配")
# import requests # # url_zd = 'http://192.168.236.187/zd' # headers = {  # 设置请求头 #     'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0' # } # param_zd ={ #     'search':'s' # }  # params 接收一个字典或者字符串的查询参数,字典类型自动转换为url编码 # response = requests.get(url=url_zd, headers=headers, params=param_zd) # # 查看响应状态码 # print(response.status_code) # # 查看响应头部字符编码 # print(response.encoding) # 查看完整url地址 # print(response.url) # 查看响应内容,response.text 返回的是Unicode格式的数据 # print(response.text)
# User_lit=['gege','xiaoye'] # pows_lit=['123456','12312']
# import requests
# url_zd = "http://192.168.236.141/zd/user/user.php"
# headers = {  # 设置请求头 #     'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0' # } # for use in User_lit: #     for pows in pows_lit: #         param_zd ={
#             'user':use, #             'pass':pows, #             'submit':'%E7%99%BB%E5%BD%95' #         } #         response = requests.post(url=url_zd, headers=headers,data=param_zd).apparent_encoding #         if response.find('utf-8'): #             print(response.status_code) #             print(response.apparent_encoding)

# import re # import requests # def getHTMLtext(url): #     try: #         r = requests.get(url,timeout=30) #         r.raise_for_status() #         print(r.apparent_encoding) #         r.encoding = r.apparent_encoding #         return r.text #     except: #         return "产生异常" # print(getHTMLtext('http://www.baidu.com'))

标签:10,set,python,练习,list,range,input,print,一些
From: https://www.cnblogs.com/ftcyou/p/16793112.html

相关文章

  • 进入python的世界_day15_python基础——内置函数、迭代器、异常捕获
    一、一些重要内置函数、常见内置函数1..zip()​ 将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的zip对象,转成list即可查看,如果对应......
  • 从零开始撸python
    Day4:多线程聊天室这个比较简单,用来练一下手,不过发现一个问题,多线程用while循环的时候,不论循环条件,CPU占用直接拉满,但用列表for循环却可以,应该是和操作系统原理有关,希望知......
  • python 文件的写操作
    1写操作快速入门打开文件f=open("python.txt","w")文件写入f.write("helloworld")内容刷新f.flush()注意:直接调用write,内容并未真正写入文件,而是会积攒在程......
  • python进阶之路14 之函数内置方法、可迭代对象、异常捕获处理
    重要内置函数1.map()映射l1=[1,2,3,4,5]#deffunc(a):# returna+1res=map(lambdax:x+1,l1)print(list(res))......
  • python 文件练习
    题目通过Windows的文本编辑器软件,将如下内容,复制并保存到:word.txt,文件可以存储在任意位置itheimaitcastpythonitheimapythonitcastbeijingshanghaiitheimas......
  • python基础-内置函数、可迭代对象、迭代器对象、异常捕获
    python基础-内置函数、可迭代对象、迭代器对象、异常捕获目录一、重要内置函数1.zip2.filter过滤3.sorted升序排序二、常见内置函数1.abs()绝对值2.all()3.any()4.bin二进......
  • 网络基础专项练习
    1.国际标准化组织ISO提出的不基于特定机型,操作系统或公司的网络体系结构OSI参考模型包括七层:第七层:应用层第一层:表示层第一层:会话层第一层:运输层第一层:网络层第一层:......
  • python2 接口下载文件,文件名设置中文无效解决方案
    fromurllibimportquote_file_name=quote("测试".encode("utf-8"))data=models.AdaptationPChannel.export_active_project(start_date)response=HttpResponse......
  • Python学习路程——Day15
    Python学习路程——Day15重要内置函数zip()'''zip()函数的作用 zip()函数可以将多个序列(列表、元组、字典、集合、字符串以及ranger()区间构成的列表压缩成一个zip对......
  • RxJS 系列 – 实战练习
    前言这篇主要是给一些简单例子,从中体会RxJS在管理上的思路.  SlideDownEffectwithDynamicContent我在这篇 CSS&JSEffect–FAQAccordion&SlideDow......