这是我半学期学习的python入门的代码
# _*_ coding:utf-8 _*_
# ege = '16'
# t = '174.5'
# print('我的名字叫李明,我今年'+ege,'岁,身高'+t)
# print('我的名字叫\'李明\',我今年'+ege,'岁,身高'+t)
# ot= 172.5
# # t = ot+2
# # print('李明今年的身高为',t)z
# y = 2002
# z = 2020
# print('李明的年龄为',z-y)
# zhanghua = 15
# # wangfeng = 16
# # if zhanghua < wangfeng:
# # print('wangfengda')
# #
# # elif zhanghua == wangfeng:
# # print('yiyangda')
# #
# # else :
# # print('zhanghuada')
# zimu= "Hello Python"
# zi= "h"
# result = zi in zimu
# print(result)
# a = 20
# b = 20
# print(a is b)
# print(0.4-0.1 != 0.3)
# print(0.4 - 0.1)
# x = 6+ 8j
# print('实部为',x.real)
# print('虚部为',x.imag)
# print('模为',abs(x))
# print('共轭复数为',x.conjugate())
#
# a = [97, 98, 99,100]
# b = (97, 98, 99,100)
# c = {'x':97, 'y':98, 'z':99,'q':100}
# d = {97, 98, 99,100}
# print(a[1])
# print(b[1])
# print(c[1])
# print(d[1])
# print(c['q'])
# print(2 or 3)
# print(2 and 3)
# print(2 and 3 and True)
# print(0 and 3 and 1)
# print(0 and 3 or 1)
# print(0 and 3 or 1 or 4)
# print(0 or False and 1)
# a = int(input("请输入一个数:"))
# print("其对应二进制为{:b}\n八进制为{:o}\n十六进制为{:x}".format(a,a,a))
#
#
# setA = eval(input("请输入一个集合:"))
# setB = eval(input("请输入一个集合:"))
# print("交集:", setA | setB)
# print("并集:", setA & setB)
# print("setA-setB:", setA - setB)
# a = float(input())
# b = float(input())
# c = float(input())
# if (a + b > c) & (a + c > b) & (b + c > a):
# # 计算半周长
# s = (a + b + c) / 2
#
# # 计算面积
# area = (s * (s - a) * (s - b) * (s - c)) ** 0.5
# print('三角形面积为 %0.2f' % area)
# else:
# print('无法构成三角形')
# a=int(input())
# # b=0
# # while a>0:
# # b=b*10+a%10
# # a//=10
# # print(b)
# x = input()
# y = sum(map(int,x))
# print(y)
# x = input("Please input a Num:")
# l = len(x)
# x = int(x)
# z = 0
# while l > 0:
# y = x//(10 ** (l - 1))
# z = z + y
# x = x - y*(10 ** (l - 1))
# #测试
#
# l = l - 1
#
# print(z)
# list = ['Google', 'Runoob', 1997, 2000]
#
# print("第三个元素为 : ", list[2])
# tup1 = (12, 34.56)
# tup2 = ('abc', 'xyz')
#
# tup3 = tup1 + tup2
# print(tup3)
#
# dict = {'Name': 'xxx', 'Age': 17, 'Name': 'xxx'}
#
# print("dict['Name']: ", dict['Name'])
i=1
#定义一个变量sum为0,用来存放和
# sum=0
# for i in range(0,10000):
#
# sum+=i
# i+=1
# print(sum)
# for i in range(3,30):
# if i % 3 == 0:
# print(i)
# print([x*x*x for x in range(10)])
# import math
# def prime(n):
# return filter(lambda x: not [x % i for i in range(2, int(math.sqrt(x)) + 1) if x % i == 0], range(2, n + 1))
# print(prime(100))
#
# dlist = [1,2,3,4,5,6,7,8,9,0]
# x = min(dlist) # 最小值
# print(x)
# d = max(dlist) # 最大值
# print(d)
# h = sum(dlist) # 总 和
# print(h)
# x = list('Python') #创建类别对象
# print(x)
# print(x[0]) #下标为0的元素,第一个元素
# print(x[-1]) #下标为-1的元素,最后一个元素
# li=['alex','eric','rain']
# print(len(li))
# li.append('servn')
# print(li)
# li.insert(0,'tony')
# print(li)
# li[0]='kelly'
# print(li)
# li.remove('eric')
# print(li)
# name=li.pop(1)
# print(name,li)
# li.pop(2)
# print(li)
# del li[1:3]
# print(li)
# print(list(enumerate(li)))
# for name in li:
# print(name)
# num=list(range(1,100001))
# for shu in num:
# print(shu)
# print(max(num))
# print(min(num))
# print(sum(num))
# digits=list(range(3,31,3))
# for di in digits:
# print(di)
# li = [value**3 for value in range(1,11)]
# print(li)
# from math import sqrt
# n=int(input())
# li=[]
# for x in range(2,n):
# flag=1
# for i in range(2,int(sqrt(x)+1)):
# if x%i==0:
# flag=0
# break
# if flag==1:
# li.append(x)
# print(li)
# a = 'Python'
# print(a[1:4])
# print(a)
# print(a[:4])
# print(a[1:])
# print(a[::])
# print(a[::2])
# print(a[::-1])
# print(a[:100])
# print(a[100:])
# tu = ('alex','eric','rain')
# print(len(tu))
# print(tu[1])
# print(tu[:2])
# for t in tu:
# print(t)
# print(tuple(enumerate(tu,10)))
# li=input().split()
# for i in range(0,len(li)-1):
# for j in range(0,len(li)-1-i):
# if int(li[j])>int(li[j+1]):
# t=int(li[j])
# li[j]=int(li[j+1])
# li[j+1]=t
# print(li)
# import string
# import random
# s=string.digits+string.ascii_uppercase+string.ascii_lowercase
# for i in range(0,10):
# print(random.sample(s,8))
# x = dict()
# print (type(x))
# x = {}
# keys = ['a', 'b', 'c', 'd']
# values = [1, 2, 3, 4]
# dictionary = dict(zip(keys, values))
# d = dict(name='Dong', age=39)
# aDict = dict.fromkeys(['name', 'age', 'sex'])
# print (aDict)
# aDict = {'server': 'db.diveintopython3.org', 'database': 'mysql'}
# del aDict
# # print(aDict)
# aDict = {'age': 39, 'score': [98, 97], 'name': 'Dong', 'sex': 'male'}
# print (aDict['age'])
# print (aDict.get('age'))
# print (aDict.get('address', 'Not Exists.'))
# aDict = {'age': 35, 'name': 'Dong', 'sex': 'male'}
# aDict['age'] = 39
# print (aDict)
# aDict['address'] = 'SDIBT'
# print (aDict)
# aDict.update({'age':36})
# print (aDict)
# str1 = "明月几时有,把酒问青天。不知天上宫阙,今夕是何年?我欲乘风归去,又恐琼楼玉宇,高处不胜寒。起舞弄清影,何似在人间!转朱阁,低绮户,照无眠。不应有恨,何事长向别时圆?人有悲欢离合,月有阴晴圆缺,此事古难全。但愿人长久,千里共婵娟。"
# dict1 = dict()
# for i in str1:
# dict1[i] = dict1.get(i,0)+1
# print(dict1)
# import collections
# f = open(r"new.txt", encoding="utf-8")
# a = f.read().split()
# print(a)
# print(collections.Counter(a))
# words_dic = {}
# for k in a:
# if k in words_dic:
# words_dic[k] += 1
# else:
# words_dic[k] = 1
# print(words_dic)
# f.close()
# factor=(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2)
# last=("1","0","X","9","8","7","6","5","4","3","2")
# s=("1","0","9","8","7","6","5","4","3","2")
# print("请输入你的身份证号:")
# flag=1
# while flag:
# a=str(input())
# if len(a)==18:
# f=1
# for i in range(17):
# if a[i] not in s:
# f=0
# break
# if f == 1 and (a[17] in last):
# flag=0
# else:
# print("请重新输入:")
# else:
# print("请重新输入:")
# sum=0
# for i in range(17):
# sum += int(a[i])*factor[i]
# if last[sum%11] == a[17]:
# print("合格!")
# else:
# print("不合格!")
# import requests #导入requests包
# requests.packages.urllib3.disable_warnings()#避免报错
# url = 'http://www.kbaidu.com/'
# strhtml = requests.get(url,verify=False) #Get方式获取网页数据 verify=False避免ssl认证
# print(strhtml.text)
#
#
# import re
# import time
# import requests
# import urllib.request
# from bs4 import BeautifulSoup
#
# firefoxHead = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"}
# IPRegular = r"(([1-9]?\d|1\d{2}|2[0-4]\d|25[0-5]).){3}([1-9]?\d|1\d{2}|2[0-4]\d|25[0-5])"
# host = "https://www.ieqq.net/?buyok=1"
# url = "https://www.ieqq.net/user/login.php"
#
# codes = ["82983127", "82990355", "82990200", "82658116", "82020121", "82990050", "82982895", "82982662", "82658116",
# "82982393", "82872754", "82726306", "82222074", "82019494", "80894466", "80895722",
# "80895400", "80895382", "80895361", "80895331", "80895117"]
#
#
# def parseIPList(url="http://www.xicidaili.com/"):
# IPs = []
# request = urllib.request.Request(url, headers=firefoxHead)
# response = urllib.request.urlopen(request)
# soup = BeautifulSoup(response, "lxml")
# tds = soup.find_all("td")
# for td in tds:
# string = str(td.string)
# if re.search(IPRegular, string):
# IPs.append(string)
# return IPs
#
#
# def PV(IP):
# s = requests.Session()
# s.headers = firefoxHead
#
# for i in range(len(codes)):
# print("No.{}\t".format(i), end="\t")
# s.proxies = {"http": "{}:8080".format(IP)}
# s.get(host)
# r = s.get(url.format(codes[i]))
# html = r.text
# soup = BeautifulSoup(html, "html.parser")
# spans = soup.find_all("span")
# # print(spans[2].string)
# time.sleep(2)
#
#
# def main():
# IPs = parseIPList()
# for i in range(50000):
# print("正在进行第{}次访问\t".format(i), end=" ")
# PV(IPs[i])
#
#
# if __name__ == "__main__":
# main()
# import qrcode
# img = qrcode.make('hello')
# img.save('test.png')
# import pyzbar.pyzbar as pyzbar
# from PIL import Image,ImageEnhance
# image = "test.png"
# img = Image.open(image)
# img.show()
# texts = pyzbar.decode(img)
# #输出结果
# for text in texts:
# tt = text.data.decode("utf-8")
# print(tt)
# for x in range(0,1000):
# if x % 3 == 0 and x % 7 == 0 and x % 5 != 0:
# print(x)
# import random
# def ranstr(num):
# # 猜猜变量名为啥叫 H
# H = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
# salt = ''
# for i in range(num):
# salt += random.choice(H)
# return salt
# salt = ranstr(6)
# print(salt)
# sumer = 0
# # sum = 0
# # for i in range(1,10):
# # sumer += i;
# # sum += sumer
# # print(sum)
# n = 0
# s = 0
# for i in range(1,10):
# if i%2 == 0:
# n += i
# else:
# s += i;
#
# print("奇数和:",n)
# print("偶数和:",s)
# list = []
# while True:
# sum = int(input())
# if sum == 0:
# break
# else:
# list.append(sum)
#
# print("最大:",max(list),"最小:".min(list))
# import tkinter as tk
#
# class APP:
# def __init__(self, master):
# frame = tk.Frame(master)
# frame.pack(side=tk.LEFT, padx=10, pady=10)
#
# self.hi_there = tk.Button(frame, text="打招呼", bg="black", fg="white", command=self.say_hi)
# self.hi_there.pack()
#
# def say_hi(self):
# print("互联网的广大朋友们大家好,我是闫晋文!")
#
# root = tk.Tk()
# app = APP(root)
#
# root.mainloop()
# for i in range(1,3):
#
# for j in range(2,5):
#
# print(i*j)
# s=10
#
# for i in range(1,6):
#
# while True:
#
# if i%2==1:
#
# break
#
# else:
#
# s-=1
#
# break
#
# print(s)
# k=1
#
# n=263
#
# while n:
#
# k*=n%10
#
# n//=10
#
# print(k)
# for i in range(1,3):
#
# for j in range(2,5):
#
# print(i*j)
# sum = 0
# for i in (10,9,8,7,6,5,4,3,2,1):
# print(i)
# sum += i
# print(sum)
#
# x = float(input())
# if x>0:
# print(x)
# else:
# print(abs(x))
#
# i = int(input())
# u = int(input())
# if u<=12:
# print(4000)
# else:
# print(4000+200*(u-12))
# 4.3
# x = ord(input())
# if x>=48 and x<=57:
# print("数字")
# elif x>=65 and x<=90:
# print("大写字母")
# elif x>=97 and x<=122:
# print("小写字母")
# else:
# print("其他字符")
# 4.4
#
# x = int(input())
# s = 0
# for i in range(1,x+1):
# s = s + i
# print(s)
# 4.5
# a = 1
# b = 1
# x = int(input())
# for i in range(1,x+1):
# if i<=2:
# print(1)
# else:
# c = a + b
# a = b
# b = c
# print(c)
# 4.6
# s = 0
# x = 0
# for i in range(1,11):
# x += i
# s += x
# print(s)
# 4.7
# s = 0
# n = 1
# for i in range(1,11):
# if i%2==0:
# n*=i
# else:
# s+=i
# print(s,n)
# 4.8
#
# x = 1
# a = 0
# while x:
# x = int(input())
# s = max(x,a)
# a = s
# print("最大数为:",s)
# 4.9
# 4.10
# for i in range(7, 1001):
# if i % 2 == 1 and i % 3 == 2 and i % 4 == 3 and i % 5 == 4 and i % 6 == 5 and i % 7 == 0:
# print(i)
# break
# a = True
# # # b = False
# # # num = 0
# # # while a:
# # # num += 1
# # # print(num)
# # # if num > 50:
# # # b = True
# # # a = False
# # # break
# # #
# # # for i in range(0,50):
# # # num -= 1
# # # print(num)
# # # if num < 1:
# # # a = True
# # # b = False
# # # break
#
# import paramiko # 用于调用scp命令
# from scp import SCPClient
#
#
# # 将指定目录的图片文件上传到服务器指定目录
# # remote_path远程服务器目录
# # file_path本地文件夹路径
# # img_name是file_path本地文件夹路径下面的文件名称
# def upload_img(img_name, remote_path="/var/www/html/public/thinkfont/competitor/data/font/oppo/preview_pic",
# file_path="D:\PythonProject\img"):
# # img_name示例:07670ff76fc14ab496b0dd411a33ac95-6.webp
# host = "***.***.***.***" # 服务器ip地址
# port = 22 # 端口号
# username = "duanyuanjin" # ssh 用户名
# password = "duanVlife" # 密码
#
# ssh_client = paramiko.SSHClient()
# ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy)
# ssh_client.connect(host, port, username, password)
# scpclient = SCPClient(ssh_client.get_transport(), socket_timeout=15.0)
# local_path = file_path + "\\" + img_name
# try:
# scpclient.put(local_path, remote_path)
# except FileNotFoundError as e:
# print(e)
# print("系统找不到指定文件" + local_path)
# else:
# print("文件上传成功")
# ssh_client.close()
# def S(x,y,h):
# return (x+y)*h/2
# x = int(input("输入上底:"))
# y = int(input("输入下底:"))
# z = int(input("输入高:"))
# print("梯形面积时:",S(x,y,z))
# def calnum(num):
# for i in (0,num+1):
# if num != 1:
# csum = num * calnum(num - 1)
# else:
# csum = 1
# return csum
# def demo1(N=10):
#
# return sum(calnum(x) for x in range(1,N+1))
#
# num = int(input("请输入正整数:"))
# ret = demo1(num)
# print("{}项的阶乘和为:{}".format(num,ret))
# import math
# def Sle(a, b, c):
# try:
# p = (a + b + c) / 2
# S=math.sqrt(p*(p - a)*(p - b)*(p - c))
# return S
# except:
# print("输入有问题")
# x = int(input("输入一边长:"))
# y = int(input("输入一边长:"))
# z = int(input("输入一边长:"))
# if(x+y>z)and(x+z>y)and(y+z>x):
# print(Sle(x,y,z))
# else:
# print("无法构成三角形")
#
# def day(year, month):
# if month >12 or month <= 0:
# return -1
# if month == 2:
# return 29 if year % 4 == 0 and year % 100 != 0 or year % 400 == 0 else 28
#
# if month in (4, 6, 9, 11):
# return 30
# else:
# return 31
# year = int(input("请输入年份:"))
# month = int(input("请输入月份:"))
# print(day(year,month))
#
# def SFM(t,m,s):
# if(s == 59):
# s = 0
# m += 1
# if(m == 60):
# m = 0
# t += 1
# if(t == 24):
# t = 0
# else:
# s += 1
# return t,m,s
# t = int(input("输入小时:"))
# m = int(input("输入分数:"))
# s = int(input("输入秒数:"))
# t,m,s = SFM(t,m,s)
# print("输入时间的下一秒是{}时{}分{}秒".format(t,m,s))
#
# import random
# def Game():
# for i in range(0,6):
# num = int(input("请输入猜测数:"))
# if num > rannum:
# print("猜大了")
# elif num < rannum:
# print("猜小了")
# else:
# print("恭喜你答对了,开始下一轮游戏")
# break
# print("你没有在规定次数完成游戏,开始下一轮游戏")
# while True:
# try:
# rannum = random.randint(0, 50)
# Game()
# except:
# pass
# def ff(x,y=100):
# return {x:y}
# print(ff(y=10,x=20))
# f=lambda x,y:{x:y}
# print(f(5,10))
# f=[lambda x=1:x*2,lambda x:x**2]
# x = (lambda x:x**2)
# print(x(4))
# print((f[1](3)))
#
# def fun (li):
# for i in range(len(li)):
# k=i
# for j in range(i+1,len(li)):
# if li[k]>li[j]:
# k=j
# li[k],li[i]=li[i],li[k]
# return li
# s=input("以空格隔开:").split(" ")
# lis=[]
# for i in range(len(s)):
# lis.append(int(s[i]))
# print(fun(lis))
# def find(li,x,min,max):
# if min>max:
# print("False")
# return
# mid=int((min+max)/2)
# if x==li[mid]:
# print("True")
# return
# elif x>li[mid]:
# find(li,x,mid+1,max)
# elif x<li[mid]:
# find(li,x,min,mid-1)
# s = list(map(int,input("以空格隔开:").split()))
# a=int(input("请输入你要查找的数:"))
# find(s,a,0,len(s))
# def _List(li):
# dp=[]
# for i in range(len(li)):
# dp.append([li[i]])
# for i in range(len(li)):
# for j in range(i):
# if li[i]>li[j]:
# if len(dp[i])<len(dp[j])+1:
# dp[i]=dp[j]+[li[i]]
# print("最长子序列:",dp)
# le=0
# for i in range(len(dp)):
# if le<len(dp[i]):
# le=len(dp[i])
# Lis=dp[i]
# return le,Lis
# arr = list(map(int,input("输入序列").split()))
# print("原列表:",arr)
# L,li=_List(arr)
# print("最长子序列的长度为:",L,"\n最长子序列为:",li)
# def Minn(arr):
# arr.sort()
# mi=arr[1]-arr[0]
# for i in range(len(arr)-1):
# if mi>arr[i+1]-arr[i]:
# mi=arr[i+1]-arr[i]
# a,b=arr[i],arr[i+1]
# return a,b
# li=list(map(int,input("输入序列").split()))
# print("列表:",li)
# print("相差最小的两个数字为:",Minn(li))
# import random
# # def Number(n):
# # times=0
# # for i in range(n):
# # x=random.uniform(-1,1)
# # y=random.uniform(-1,1)
# # print(x*x+y*y)
# # if x*x+y*y<1:
# # times+=1
# # print(times)
# # print(4.0*times/n)
# # n=int(input("请输入次数:"))
# # Number(n)
# class Student:
# count = 0 # 类属性 记录班里一共多少个学生
#
# def __init__(self, name, sex, age,id,Department, major , clas): # 初始化,构造函数
# self.name = name
# self.age = age
# self.sex = sex
# self.id = id
# self.Department = Department
# self.major = major
# self.clas = clas
# def show(self):
# print(f"欢迎新同学{self.name},{self.sex},{self.age},{self.id},{self.Department},{self.major},{self.clas}")
# Student.count += 1 # 每次被实例化一次班里学生+1
#
# def main():
#
# zs = Student("张三","男",20,123123,"信息工程学院","物联网工程","一班")
# zs = Student("张1", "男", 20, 123123, "信息工程学院", "物联网工程", "一班")
# zs.show()
#
#
#
# main()
# def lis(arr):
#
# n = len(arr)
#
# m = [0] * n
#
# for x in range(n - 2, -1, -1):
#
# for y in range(n - 1, x, -1):
#
# if arr[x] < arr[y] and m[x] <= m[y]:
#
# m[x] += 1
#
# max_value = max(m)
#
# result = []
#
# for i in range(n):
#
# if m[i] == max_value:
#
# result.append(arr[i])
#
# max_value -= 1
#
# return result
#
# arr = [10, 22, 9, 33, 21, 50, 41, 60, 80]
#
# print(lis(arr))
# class Point:
#
# x=10
#
# y=10
#
# def __init__(self,x,y):
#
# self.x=x
#
# self.y=y
#
# pt=Point(20,20)
#
# print(pt.x,pt.y)
# class C():
#
# f=10
#
# class C1(C):
#
# pass
#
# print(C.f,C1.f)
# class Account:
#
# def __init__(self,id):
#
# self.id=id
#
# id=888
#
# acc=Account(100)
#
# print(acc.id)
# class parent:
#
# def __init__(self,param):
#
# self.v1=param
#
# class child(parent):
#
# def __init__(self,param):
#
# parent.__init__(self,param)
#
# self.v2=param
#
# obj=child(100)
#
# print(obj.v1,obj.v2)
# class account:
#
# def __init__(self,id,balance):
#
# self.id=id
#
# self.balance=balance
#
# def deposit(self,amount):
#
# self.balance+=amount
#
# def withdraw(self,amount):
#
# self.balance-=amount
#
# acc1=account('1234',100)
#
# acc1.deposit(500)
#
# acc1.withdraw(200)
#
# print(acc1.balance)
# 1.
# class yearmoney:
# # def Money(self):
# # self.money=float(input("1.请输入贷款金额:"))
# # def Year(self):
# # n=0
# # while(n not in [1,2,3]):
# # print("请选择贷款年限:1.3年(36个月)2.5年(60个月)3.20年(240个月)")
# # n=int(input())
# # if n==1:
# # Month=(self.money+self.money*0.0603)/36.0
# # elif n==2:
# # Month=(self.money+self.money*0.0612)/60.0
# # elif n==3:
# # Month=(self.money+self.money*0.0439)/240.0
# # else :
# # print("输入有误!")
# # print("月供为:","%.6f"%Month)
# # yearmoney=yearmoney()
# # yearmoney.Money()
# # yearmoney.Year()
# class Animal(object):
# def __init__(self,age):
# self.age=age
# def print_info(self):
# print("我今年%s岁了!"%self.age)
# class Bird(Animal):
# def __init__(self ,color, age):
# super().__init__(age)
# self.color=color
# def Bird_print_info(self):
# print("2.我是一只%s的鸟!"%self.color)
# Animal.print_info(self)
# class Fish(Animal):
# def __init__(self, weight, age):
# super().__init__(age)
# self.weight=weight
# def Fish_print_info(self):
# print("我是一只%s斤的鱼!"%self.weight)
# Animal.print_info(self)
# bird=Bird("红色",4)
# bird.Bird_print_info()
# fish=Fish(5,2)
# fish.Fish_print_info()
# class Player:
# def __init__(self,name,blood):
# self.name=name
# self.blood=blood
# print("玩家%s创建成功,血量为%s"%(self.name,self.blood))
# def Outfit(self,weapon):
# self.wname=weapon.name
# self.weapon_type=weapon.weapon_type
# self.lethal=weapon.lethal
# print("%s已装备%s%s,杀伤力为%s"%(self.name,self.weapon_type,self.wname,self.lethal))
# def Hit(self,p):
# self.blood-=p.lethal
# print("玩家%s使用%s对玩家%s造成%s伤害"%(p.name,p.wname,self.name,p.lethal))
# if self.blood<=0:
# print("玩家%s死亡"%self.name)
# else:
# print("玩家%s剩余%s血量"%(self.name,self.blood))
# class Weapon:
# def __init__(self,name,weapon_type,lethal):
# self.name=name
# self.weapon_type=weapon_type
# self.lethal=lethal
# w1=Weapon("M4A1","步枪",40)
# w2=Weapon("98k","狙击枪",90)
# p1=Player("小明",100)
# p2=Player("小红",100)
# p1.Outfit(w1)
# p2.Hit(p1)
# class Student(object):
# def __init__(self,Sname,Sno,Sage):
# self._Sno=Sno
# self._Sname=Sname
# self._Sage=Sage
# @property
# def Sno(self):
# return self._Sno
# @property
# def Sname(self):
# return self._Sname
# def __get(self):
# return self._Sage
# def __set(self, v):
# self._Sage = v
# Sage = property(__get, __set)
# def __str__(self):
# return "我叫%s,学号是%s,年龄为%s,是一名学生"%(self._Sname,self._Sno,self._Sage)
# class Gra_student(Student):
# def __init__(self, Sname, Sno, Sage, research):
# Student.__init__(self,Sname, Sno, Sage)
# self.setResearch(research)
# def setResearch(self,research):
# if type(research) != str:
# raise Exception('department must be a string.')
# self._research=research
# def __str__(self):
# return "我叫%s,学号是%s,年龄为%s,是一名研究生,研究方向是%s"%(self._Sname,self._Sno,self._Sage,self._research)
# s=Student('李四','1101',23)
# print(s)
# s.Sage=33
# print(s)
# ga=Gra_student('张三','1102',35,'complex network')
# print(ga)
#
# class Vector3:
# def __init__(self, x, y, z):
# self.__x = x
# self.__y = y
# self.__z = z
# def __add__(self, anotherPoint):
# x = self.__x + anotherPoint.__x
# y = self.__y + anotherPoint.__y
# z = self.__z + anotherPoint.__z
# return Vector3(x, y, z)
# def __sub__(self, anotherPoint):
# x = self.__x - anotherPoint.__x
# y = self.__y - anotherPoint.__y
# z = self.__z - anotherPoint.__z
# return Vector3(x, y, z)
# def __mul__(self, a):
# x = self.__x *a
# y = self.__y *a
# z = self.__z *a
# return Vector3(x, y, z)
# def __truediv__(self,b):
# x = self.__x /b
# y = self.__y /b
# z = self.__z /b
# return Vector3(x, y, z)
# @property
# def length(self):
# return "%.6f"%(self.__x**2+self.__y**2+self.__z**2)**0.5
# def __str__(self):
# return "%s,%s,%s"%(self.__x,self.__y,self.__z)
# v1 = Vector3(35, 44, 53)
# print("v1的坐标为",v1)
# v2 = Vector3(57, 66, 75)
# print("v2的坐标为",v2)
# print("v1+v2的坐标为",v1+v2)
# print("v1-v2的坐标为",v1-v2)
# print("v1*3的坐标为",v1*3)
# print("v2/2的坐标为",v2/2)
# print("v1的向量为",v1.length)
# print("v2的向量为",v2.length)
#
#
# import tkinter as tk
#
# window = tk.Tk()
# window.title('my window')
# window.geometry('480x360')
#
# e = tk.Entry(window,show=None)
# e.pack()
# e.insert(0,'1号润滑油剩余低于60%')
# d = tk.Entry(window,show=None)
# d.pack()
# d.insert(0,'2号润滑油剩余低于30%')
# f = tk.Entry(window,show=None)
# f.pack()
# f.insert(0,'3号润滑油剩余低于30%')
#
# window.mainloop()
# s='abcdefg'
# print(s[-2:-5])
# print(s[::-1])
# print(s[3:5])
# print(s[:5])
# for i in range(1, 10):
# for j in range(1, i+1):
# print('{}x{}={}\t'.format(j, i, i*j), end='')
# print()
# import random
# import string
#
# def generate_random_str(randomlength):
# str_list = [random.choice(string.digits + string.ascii_letters) for i in range(randomlength)]
# random_str = ''.join(str_list)
# return random_str
# num = int(input("输入验证码长度:"))
# print(generate_random_str(num))
#
# import jieba
# str_text = "中华人民共和国是伟大的国家"
# print("精简:")
# print(','.join(jieba.cut(str_text)))
# print("全模式:")
# print(','.join(jieba.cut(str_text,cut_all = True)))
# print("搜索引擎:")
# print(','.join(jieba.cut_for_search(str_text)))
# import jieba
#
# article = open('三国演义.txt', 'rb').read()#读取
# words = jieba.lcut(article)#取词
#
# nums = {}
# for word in words:#判断所取词
# if len(word) == 1 :
# continue
# elif word in ['丞相', '孟德','曹操']:
# nums['曹操'] = nums.get('曹操', 0) + 1
# elif word in ['孔明', '诸葛亮', '卧龙', '伏龙', '武乡侯', '忠武侯', '蜀相']:
# nums['孔明'] = nums.get('孔明', 0) + 1
# elif word in ['玄德曰', '玄德', '刘豫州', '汉中王', '汉昭烈帝', '平原相', '汉室宗亲', '中山靖王之后', '刘皇叔']:
# nums['刘备'] = nums.get('刘备', 0) + 1
# elif word in ['关公', '云长', '寿亭侯', '关云长']:
# nums['关羽'] = nums.get('关羽', 0) + 1
# elif word in ['都督', '周郎', '公瑾']:
# nums['周瑜'] = nums.get('周瑜', 0) + 1
# elif word in ['飞将', '吕温侯', '奉先', '吕奉先']:
# nums['吕布'] = nums.get('吕布', 0) + 1
# elif word in ['常胜将军', '子龙', '赵子龙']:
# nums['赵云'] = nums.get('赵云', 0) + 1
# else:
# nums[word] = nums.get(word, 0) + 1
# numslist = list(nums.items())
# numslist.sort(key=lambda x: x[1], reverse=True)
# word, count = numslist[1]
# print("{} {}".format(word, count))
# import string
# pwd = input("请输入密码:")
# passwd_strong = 0
# strpun = ""
# if len(pwd) > 8:
#
# for i in pwd:
# if i.isalnum():
# strpun += "1"
# elif i in string.punctuation:
# strpun += "2"
# else:
# strpun += "3"
# if "1" in strpun :
# passwd_strong +=1
# if "2" in strpun:
# passwd_strong += 1
# if "3" in strpun:
# passwd_strong += 1
# if passwd_strong == 1:
# print("密码强度为弱")
# elif passwd_strong == 2:
# print("密码强度为较强")
# elif passwd_strong == 3:
# print("密码强度为强")
#
# else:
# print("您输入的不符合标准")
# import matplotlib.pyplot as plt
# from matplotlib import animation
# import numpy as np
# import math
#
# t = np.linspace(0, math.pi, 1000)
# x = np.sin(t)
# y = np.cos(t) + np.power(x, 2.0 / 3) # 心型曲线的参数方程
#
# plt.scatter(x, y, c=y, cmap=plt.cm.Reds, edgecolor='none', s=40)
# plt.scatter(-x, y, c=y, cmap=plt.cm.Reds, edgecolor='none', s=40) # 渐变颜色曲线
# plt.axis([-2, 2, -2, 2]) # 坐标轴范围
# plt.xlabel('love', fontsize=14)
# plt.ylabel('you', fontsize=14)
# plt.title("I love you", fontsize=30)
# plt.show()
# from numpy import *
# from mayavi import mlab
#
# # Create the data.
# dphi, dtheta = pi/20.0, pi/20.0
# [phi,theta] = mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta]
# m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4;
# r = sin(m0*phi)**m1 + cos(m2*phi)**m3 + sin(m4*theta)**m5 + cos(m6*theta)**m7
# x = r*sin(phi)*cos(theta)
# y = r*cos(phi)
# z = r*sin(phi)*sin(theta)
#
# # View it.
# s = mlab.mesh(x, y, z, representation="wireframe", line_width=1.0 )
#
# mlab.show()
python入门
最新推荐文章于 2022-10-14 10:55:30 发布