• python实例代码介绍python基础知识


    TODO: 知识点仍有待整理

    import

    使用 import 关键字可以让你选择性地导入所需的模块,而不必导入整个模块库。这样可以减少内存占用和加载时间,尤其是当你只需要使用模块中的某些功能时。

    同时,使用 import 可以提高代码的可读性和可维护性,因为你可以明确指定所需的模块,而不必导入整个库。

    另外,使用 import 还可以避免命名冲突。如果你导入整个库,可能会有一些与你自己的代码冲突的名称。但是,如果你只导入所需的模块,你可以更好地控制命名空间,避免冲突。

    #!/usr/bin/env python3
    #-*- coding: utf-8 -*-
    
    # 开头都建议添加python解释器和编码声明
    # 第一行注释是为了告诉 Linux/OS X 系统,这是一个 Python 可执行程序,Windows 系统会忽略这个注释
    # 第二行注释是为了告诉 Python 解释器,按照 UTF-8 编码读取源代码,否则,你在源代码中写的中文输出可能会有乱码。
    # 申明了 UTF-8 编码并不意味着你的.py 文件就是 UTF-8 编码的,必须并且要确保文本编辑器正在使用 UTF-8 without BOM 编码
    # 如果.py文件本身使用 UTF-8 编码,并且也申明了# -*- coding: utf-8 -*-,打开命令提示符测试就可以正常显示中文
    
    # 运行脚本时带入参数,可以在main函数中用sys模块的argv获取参数值,len(sys.argv)获取参数个数
    # 如果没带参数,len(sys.argv)默认是1,表示本身自带参数为当前脚本的完整路径
    # 如:C:\Users\xxx\Desktop\PLCN1证书检查工具\PLCN1证书检查工具.py
    #if __name__ == '__main__':
    #    import sys
    #    args = sys.argv, args[1]为带的第一个参数
    #    argc = len(sys.argv)
    import argparse
    
    parser = argparse.ArgumentParser()
    parser.add_argument("loc", type=str)
    parser.add_argument('loc2', type=str, default="5555")
    parser.add_argument('--b', type=int, default=0)
    parser.add_argument('-n', "--number", type=str, help='输入一个数字')  --此时n是number的缩写,参数会存在number中,而不是n中
    args = parser.parse_args()
    
    print(args.loc, type(args.loc))
    print(args.loc2, type(args.loc2))
    print(args.b, type(args.b))
    print(args.number, type(args.number))
    
    # 执行python test.py  --b=1 --number=2 3 5
    
    
    # 打印数据
    info = " hello python "
    print(info)
    print("首字母大写输出:" + info.title())
    print("全部大写输出:" + info.upper())
    print("去除空格l-left,r-right,或两边空格:" + info.lstrip())
    print('转义字符:"打印有双引号,外面就用单引号,反过来同理"')
    print("""打印可以用三引号
        三引号支持换行
        !!!""")
    print("\t这个是tab和回车 \n")
    print_string_a = "string a"
    print_int_b = 100
    print(f'string a is: {print_string_a}, int b is : {print_int_b:.1f}')   # 类似于printf("a:%s,b:%.1f", a, b)
    print("string a is: %s int b is:%d\n" % (print_string_a, print_int_b))
    print(r'\t\n利用r参数这些转义字符不转义')
    print(print_string_a.ljust(5,'*') + "用.ljust(5,*)表示左对齐并占五个空白字符空间,后面空格用*号替代,同理可以用.center表示居中对齐, .rjust右对齐")
    
    
    # 字符串拼接
    info1 = "hello"
    info2 = "world"
    combine_info = info1 + " " + info2
    print(combine_info)
    
    # 字符串判断,判断string是否是str开头的,返回从0开始的位置
    string.startswith('str')
    
    
    # 去空格及特殊符号
    
    s.strip().lstrip().rstrip(',')
    Python strip() 方法用于移除字符串头尾指定的字符(默认为空格)。
    
    # 复制字符串
    #strcpy(sStr1,sStr2)
    sStr1 = 'strcpy'
    sStr2 = sStr1
    sStr1 = 'strcpy2'
    print sStr2
    
    # 连接字符串
    #strcat(sStr1,sStr2)
    sStr1 = 'strcat'
    sStr2 = 'append'
    sStr1 += sStr2
    print sStr1
    
    # 查找字符
    #strchr(sStr1,sStr2)
    # < 0 为未找到
    sStr1 = 'strchr'
    sStr2 = 's'
    nPos = sStr1.index(sStr2)
    print nPos
    
    # 比较字符串
    #strcmp(sStr1,sStr2)
    sStr1 = 'strchr'
    sStr2 = 'strch'
    print cmp(sStr1,sStr2)
    
    # 扫描字符串是否包含指定的字符
    #strspn(sStr1,sStr2)
    sStr1 = '12345678'
    sStr2 = '456'
    #sStr1 and chars both in sStr1 and sStr2
    print len(sStr1 and sStr2)
    
    # 字符串长度
    #strlen(sStr1)
    sStr1 = 'strlen'
    print len(sStr1)
    
    # 将字符串中的大小写转换
    #strlwr(sStr1)
    sStr1 = 'JCstrlwr'
    sStr1 = sStr1.upper()
    #sStr1 = sStr1.lower()
    print sStr1
    
    # 追加指定长度的字符串
    #strncat(sStr1,sStr2,n)
    sStr1 = '12345'
    sStr2 = 'abcdef'
    n = 3
    sStr1 += sStr2[0:n]
    print sStr1
    
    # 字符串指定长度比较
    #strncmp(sStr1,sStr2,n)
    sStr1 = '12345'
    sStr2 = '123bc'
    n = 3
    print cmp(sStr1[0:n],sStr2[0:n])
    
    # 复制指定长度的字符
    #strncpy(sStr1,sStr2,n)
    sStr1 = ''
    sStr2 = '12345'
    n = 3
    sStr1 = sStr2[0:n]
    print sStr1
    
    # 将字符串前n个字符替换为指定的字符
    #strnset(sStr1,ch,n)
    sStr1 = '12345'
    ch = 'r'
    n = 3
    sStr1 = n * ch + sStr1[3:]
    print sStr1
    
    # 扫描字符串
    #strpbrk(sStr1,sStr2)
    sStr1 = 'cekjgdklab'
    sStr2 = 'gka'
    nPos = -1
    for c in sStr1:
      if c in sStr2:
        nPos = sStr1.index(c)
        break
    print nPos
    
    # 翻转字符串
    #strrev(sStr1)
    sStr1 = 'abcdefg'
    sStr1 = sStr1[::-1]
    print sStr1
    
    # 查找字符串
    #strstr(sStr1,sStr2)
    sStr1 = 'abcdefg'
    sStr2 = 'cde'
    print sStr1.find(sStr2)
    
    # 分割字符串
    #strtok(sStr1,sStr2)
    sStr1 = 'ab,cde,fgh,ijk'
    sStr2 = ','
    sStr1 = sStr1[sStr1.find(sStr2) + 1:]
    print sStr1
    #或者
    s = 'ab,cde,fgh,ijk'
    print(s.split(','))
    
    # 连接字符串
    delimiter = ','
    mylist = ['Brazil', 'Russia', 'India', 'China']
    print delimiter.join(mylist)
    
    # 取关键字到末尾的字符串
    start_pos=string.find('keyword')
    f.write('%s\n' % string[start_pos:])
    
    # 数字的字符化
    age = 23
    print("age:" + str(age) + " half is:" + str(23/2))    # 不加str会报错,py不知道是字符2和3,还是数字23,但是可以单独打印print(age)
    
    
    # 列表(数组)
    name = ["jane", "mike", "michael"]    # []内可为空内容
    print(name)
    print("列表元素0:" + name[0] + ", 最后一个元素:" + name[-1])    # 通过下标访问,-1表示最后一个元素,-2表示倒数第二个,以此类推
    
    name[0] = "jane1"
    print("修改后的name0元素:" + name[0])
    
    name.append("append name")
    print("添加元素后的列表:" + str(name))
    
    name.insert(0, "insert name")
    print("插入元素后的列表:" + str(name))
    
    del name[0]
    print("删除了元素0后的列表:" + str(name))
    name.pop(0)    # pop和del可以认为是一个意思
    print("删除了元素0后的列表:" + str(name))
    name.remove("mike")
    print("通过值mike来删除元素:" + str(name))
    
    name.sort(reverse=True)
    print("按字母逆排序元素:" + str(name))
    name.sort()    # sort会永久修改列表
    print("按字母排序元素:" + str(name))
    print("临时排序:" + str(sorted(name, reverse=True)))    # sorted只会临时修改元素顺序,执行后name还是会恢复原来顺序
    print("还是原来的顺序:" + str(name))
    
    name.insert(0, "mike")
    name.reverse()
    print("逆序输出:" + str(name))
    
    print("列表长度:" + str(len(name)))
    
    num_list = list(range(0, 6))
    print("数字转列表:" + str(num_list))
    
    print("取范围内的元素:" + str(num_list[1:3]))    # 从num_list[1]开始取值,取3-1个
    print("取范围内的元素:" + str(num_list[:3]))    # 从开始取值,取3-0个
    
    copy_name = name
    print("列表可以直接赋值,但是如果修改了name或copy_name,都会导致两个变量值的改变\n")
    copy1_name = name[:]
    print("通过类似切片:的方式,可以创建副本并给赋值的变量,这样就是两个独立的变量了\n")
    
    if name:
        print("列表不为空")
    else:
        print("列表是空的")
    
    # for循环的使用
    students = ["stu1", "stu2", "stu3"]
    for stu in students:    # 赋值给stu,并打印
        print(stu)
    print("缩进代表着该行的代码与上一个未缩进的行的代码是一起的\n")
    
    for value in students[0:2]:
        print(value)
    
    # 不用变量,只要循环
    for _ in range(3, num_params):
        pattern = pattern + r',\s*(.*)'
    
    # 元组(不可修改的数组)
    dimensions = (1, 2, 3, 4, 5)
    print(dimensions)
    print(dimensions[0])
    # dimensions[0] = 2 # 这样将提示出错
    dimensions = (6, 7, 8, 9)    # 不能改元素值,但是可以重新赋值变量
    print(dimensions)
    
    
    # if条件语句的使用
    cars = ['audi', 'bmw', 'subaru', 'toyota']
    for car in cars:
        if car == 'bmw':    # 不等于用 !=,如果多个条件就用 and/or/ ,(a==a) and (b==b)
            print(car.upper())
        else:
            print(car.title())
    
    if 'audi' not in cars:    # not的用法
        print("audi not in cars\n")
    elif 'bmw' in cars:
        print("bmw in cars\n")
    else:    # 可以不用
        print()
    
    # 一个顾客点披萨加配料检查的例子
    available_toppings = ['mushrooms', 'olives', 'green peppers', 'pepperoni', 'pineapple', 'extra cheese']
    requested_toppings = ['mushrooms', 'french fries', 'extra cheese']
    for requested_topping in requested_toppings:
        if requested_topping in available_toppings:
            print("Adding " + requested_topping + ".")
        else:
            print("Sorry, we don't have " + requested_topping + ".")
    print("\nFinished making your pizza!")
    
    
    # 字典,类似二维数组
    bike_0 = {'color': 'red', 'price': '1000'}
    print("bike 0 color is: " + bike_0['color'])
    
    bike_0['size'] = 100
    print("添加键值对:" + str(bike_0))
    
    bike_0['size'] = 50
    print("修改字典值:" + str(bike_0))
    
    del bike_0['size']
    print("删除字典值size:" + str(bike_0))
    
    # 注意,即便遍历字典时,键—值对的返回顺序也与存储顺序不同。 Python不关心键—值对的存储顺序,而只跟踪键和值之间的关联关系
    print("遍历字典")
    for key, value in bike_0.items():
        print("key: " + key + " value: " + value)
    for name in bike_0.keys():
        print(".key方式获取关键字:" + name)
    for name in bike_0.values():
        print(".values方式获取值:" + name)
    
    bike_1 = {'color': 'blue', 'price': '500'}
    bikes = [bike_0, bike_1]
    print("字典嵌套")
    for bike in bikes:
        print(bike)
    
    # 在字典中存储列表
    bike_3 = {
        'size': '100',
        'color': ['yellow', 'white']    # 这就是列表
    }
    for bike_3_color in bike_3['color']:
        print("bike_3 color: " + bike_3_color)
    
    # 也有字典中嵌套字典的,这个稍复杂一点点,举个例子好了
    users = {
        'user1': {
            'first': 'albert',
            'last': 'einstein',
            'location': 'princeton',
        },
        'user2': {
            'first': 'marie',
            'last': 'curie',
            'location': 'paris',
        },
    }
    for username, user_info in users.items():
        print("\nUsername: " + username)
        full_name = user_info['first'] + " " + user_info['last']
        location = user_info['location']
        print("\tFull name: " + full_name.title())
        print("\tLocation: " + location.title())
    
    
    # 用户输入数据
    # input输入时默认就是字符串,要变成数字需要转化处理
    # age = input("please tell me your age: ")
    age = '100'
    print("your age is: " + age)
    age = int(age)    # float也是类似用法
    print("当前age是数字:" + str(age))
    # test_num = int(input('input num:'))  # 也可以输入时指定类型
    
    
    # while循环用法
    current_number = 1
    while current_number <= 5:
        print(current_number)
        current_number += 1
        if current_number > 3:
            break
        else:
            continue
    
    
    # 函数用法
    def greet(username, user_age=50):
        """ 三个双引号表示函数功能描述,Python使用它们来生成有关程序中函数的文档 """
        # 井号也是可以用的
        print("函数用法:hello " + username + " age: " + str(user_age))
        return True
    
    
    ret = greet('mike', 100)
    ret = greet(username='mike', user_age=100)
    ret = greet(user_age=100, username='mike')  # 指名形参,就可以不按照顺序赋值
    
    # 传递任意数量的实参,有点像指针
    def make_pizza(*toppings):
        """打印顾客点的所有配料"""
        print(toppings)
        make_pizza('pepperoni')
        make_pizza('mushrooms', 'green peppers', 'extra cheese')
    
    
    def make_pizza_2(size, *toppings):
        """概述要制作的比萨"""
        print("\nMaking a " + str(size) +
        "-inch pizza with the following toppings:")
        for topping in toppings:
            print("- " + topping)
    make_pizza_2(16, 'pepperoni')
    make_pizza_2(12, 'mushrooms', 'green peppers', 'extra cheese')
    
    
    # 将函数存储在模块中
    # 将函数存储在独立文件中后,可与其他程序员共享这些文件而不是整个程序
    # 比如将制作披萨的函数make_pizza()放在pizza.py中
    # 新建making_pizza.py,在第一行通过import pizza,就可以导入模块,再通过pizza.make_pizza()进行调用
    
    # 也可以导入模块中指定的函数,包括多个函数
    # 通过 from pizza import make_pizza1, make_pizza2 来实现,调用时直接用函数 make_pizza() 调用
    
    # 导入的函数名和现有的名称有冲突怎么办?
    # 通过导入时用as解决,具体如下:
    # from pizza import make_pizza as mp
    # 调用时:mp()
    
    # as同样可以给模块起别名,如下:
    # from pizza as p
    # 调用时:p.make()
    
    # 导入模块中的所有函数
    # from pizza import *
    
    
    # 类的使用
    class Human:  # 类的首字母是大写
        """人类动作"""
        """__init__()是一个特殊的方法,每当你根据Dog类创建新实
    例时, Python都会自动运行它。在这个方法的名称中,开头和末尾各有两个下划线,这是一种约
    定,旨在避免Python默认方法与普通方法发生名称冲突。
    我们将方法__init__()定义成了包含三个形参: self、 name和age。在这个方法的定义中,形
    参self必不可少,还必须位于其他形参的前面。为何必须在方法定义中包含形参self呢?因为
    Python调用这个__init__()方法来创建Dog实例时,将自动传入实参self。每个与类相关联的方法
    调用都自动传递实参self,它是一个指向实例本身的引用,让实例能够访问类中的属性和方法。
    我们创建Dog实例时, Python将调用Dog类的方法__init__()。我们将通过实参向Dog()传递名字和
    年龄; self会自动传递,因此我们不需要传递它。每当我们根据Dog类创建实例时,都只需给最
    后两个形参( name和age)提供值。"""
        def __init__(self, human_name, human_age):
            """初始化属性name和age"""
            self.human_name = human_name
            self.human_age = human_age
            # 类中的每个属性都必须有初始值,哪怕这个值是0或空字符串
            self.country = ""
            self.weight = 65
    
        def sit(self):
            print(self.human_name.title() + " is now sitting")
    
        def run(self):
            print(self.human_name.title() + " is running")
    
        def read_country(self):
            print("country is: " + self.country)
    
        def update_weight(self, weight):
            self.weight = weight
    
        def read_weight(self):
            print("weight is: " + str(self.weight))
    
    """
    遇到这行代码时, Python使用实参'mike'和100,调用Human类中的方法__init__()。
    方法__init__()创建一个表示特定人的示例,并使用我们提供的值来设置属性human_name和human_age。
    方法__init__()并未显式地包含return语句,但Python自动返回一个表示这个人的实例。我们将这个实例存储在变量man1中。
    """
    man1 = Human("mike", 100)
    print("man name is: " + man1.human_name + ", age: " + str(man1.human_age))
    # 调用类的方法
    man1.sit()
    man1.run()
    
    man1.read_country()
    man1.country = "china"
    man1.read_country()
    
    man1.read_weight()
    man1.update_weight(70)
    man1.read_weight()
    
    
    # 类的继承
    """
    编写类时,并非总是要从空白开始。如果你要编写的类是另一个现成类的特殊版本,可使用
    继承。一个类继承另一个类时,它将自动获得另一个类的所有属性和方法;原有的类称为父类,
    而新类称为子类。子类继承了其父类的所有属性和方法,同时还可以定义自己的属性和方法。
    
    创建子类的实例时, Python首先需要完成的任务是给父类的所有属性赋值。为此,子类的方
    法__init__()需要父类施以援手。
    """
    
    
    class AutoCar:
        """一次模拟汽车的简单尝试"""
        def __init__(self, make, model, year):
            self.make = make
            self.model = model
    
            self.year = year
            self.odometer_reading = 0
    
        def get_descriptive_name(self):
            long_name = str(self.year) + ' ' + self.make + ' ' + self.model
            return long_name.title()
    
        def read_odometer(self):
            print("This car has " + str(self.odometer_reading) + " miles on it.")
    
        def update_odometer(self, mileage):
            if mileage >= self.odometer_reading:
                self.odometer_reading = mileage
            else:
                print("You can't roll back an odometer!")
    
        def increment_odometer(self, miles):
            self.odometer_reading += miles
    
    
    class Battery1:
        """电瓶的属性"""
        def __init__(self, battery_size1=70):
            self.battery_size1 = battery_size1
    
        def describe_battery(self):
            """打印一条描述电瓶容量的消息"""
            print("This car has a " + str(self.battery_size1) + "-kWh battery.")
    
    
    class ElectricCar(AutoCar):
        """电动汽车的独特之处"""
        def __init__(self, make, model, year):
            """初始化父类的属性"""
            # 给父类的所有属性赋值,必须执行,通过super实现初始化,父类也称为超类( superclass),名称super因此而得名
            super().__init__(make, model, year)
            # 接下来定义电动汽车子类特有的属性
            self.battery_size = 70
            # 如果类的属性或方法太多,可以拎出来封装成新的类,然后再赋值给原来类的属性
            self.battery1 = Battery1()
    
        def show_battery_size(self):
            print("battery size: " + str(self.battery_size))
    
        # 父类的方法也是可以重写的,但是要和父类里面的方法名一样,比如重写read_odometer
        def read_odometer(self):
            print("can not read_odometer")
    
    
    my_tesla = ElectricCar('tesla', 'model s', 2016)
    print(my_tesla.get_descriptive_name())
    my_tesla.show_battery_size()
    
    # 如果类的属性或方法太多,可以拎出来封装成新的类,然后再赋值给原来类的属性
    my_tesla.battery1.describe_battery()
    
    
    # 类的模块化
    # 和函数的模块化一样,比如在car.py中添加了一个类Car,在my_car.py中通过以下代码就可以导入
    # from car import Car
    # 使用时就用:my_new_car = Car('bmw', '525li', 2022)
    # 类模块也可以导入其他的类模块
    
    
    # 文件操作与异常
    # 读出全部内容
    with open('read_write_test_file/file_read.txt') as file_object:
        content = file_object.read()
        print("read file, content: \n"+ content)
        # 只管用with open打开,不用close关闭,python会自己确定关闭的时机
        # file_object.close()
        """
        虽然没有close,但下面不能再用file_object了,估计是因为python已经把文件关了,读出来都是空的
        for line in file_object:
            print(line.rstrip())
        """
    #删除文件和目录,删除目录需要导入import shutil
    if os.path.isdir(cert_path):
        shutil.rmtree(cert_path)
        print("delete " + cert_path)
    if os.path.isfile(expired_list_file):
        os.unlink(expired_list_file)
        print("delete " + expired_list_file)
    
    # 逐行读取
    with open('read_write_test_file/file_read.txt') as file_object:
        for line in file_object:
            print(line.rstrip())
    
    # 逐行读取到列表中
    with open('read_write_test_file/file_read.txt') as file_object:
        lines = file_object.readlines()
    
    for line in lines:
        print(line)  # 可以用rstrip去掉空行
    
    # 读取超大文件,python对文件大小没有限制,只要内存够,多大数据都可以
    
    # 判断文件中是否包含某个关键字
    with open('read_write_test_file/file_read.txt') as file_object:
        lines = file_object.readlines()
    
    file_string = ""
    for line in lines:
        file_string += line.rstrip()
    
    print(lines)
    print(file_string)
    keyword = "123"
    if keyword in file_string:
        print("yes, appears in the file ")
    else:
        print("no, not appears in the file")
    
    # 写入文件
    with open('read_write_test_file/file_read.txt', 'a') as file_object:
        file_object.write("\nwrite words")
    with open('read_write_test_file/file_read.txt') as file_object:
        content = file_object.read()
        print(content)
    
    
    # 异常,try-except代码块的使用
    try:
        print(5/0)
    except ZeroDivisionError:
        print("You can't divide by zero!")
        # 如果不提示错误信息,让用户感知不到,就用pass语句代替打印,如下:
        # pass
    
    # 举个文件不存在的例子
    try:
        with open('file_name') as f_obj:
            contents = f_obj.read()
    # 这边知道错误的类型是FileNotFoundError,如果不知道错误的类型名,不能随便写,否则会报错,可以直接写except Exception:
    except FileNotFoundError:
        msg = "Sorry, the file does not exist."
        print(msg)
    
    
    # 让用户选择文件作为路径
        import tkinter as tk
        from tkinter import filedialog
        # 实例化
        root = tk.Tk()
        root.withdraw()
        # 获取文件夹路径
        xls_file = filedialog.askopenfilename()
        print('\n获取的文件地址:', xls_file)
    
    # 解压和压缩tar gz文件
    import os
    import tarfile
    import gzip
    
    # 一次性打包整个根目录。空子目录会被打包。
    # 如果只打包不压缩,将"w:gz"参数改为"w:"或"w"即可。
    def make_targz(output_filename, source_dir):
        with tarfile.open(output_filename, "w:gz") as tar:
            tar.add(source_dir, arcname=os.path.basename(source_dir))
    
    # 逐个添加文件打包,未打包空子目录。可过滤文件。
    # 如果只打包不压缩,将"w:gz"参数改为"w:"或"w"即可。
    def make_targz_one_by_one(output_filename, source_dir):
        tar = tarfile.open(output_filename, "w:gz")
        for root, dir, files in os.walk(source_dir):
            for file in files:
                pathfile = os.path.join(root, file)
                tar.add(pathfile)
        tar.close()
    
    
    def un_gz(file_name):
        """ungz zip file"""
        f_name = file_name.replace(".gz", "")
        # 获取文件的名称,去掉
        g_file = gzip.GzipFile(file_name)
        # 创建gzip对象
        open(f_name, "wb+").write(g_file.read())
        # gzip对象用read()打开后,写入open()建立的文件里。
        g_file.close()  # 关闭gzip对象
    
    
    def un_tar(file_name):
        # untar zip file
        tar = tarfile.open(file_name)
        names = tar.getnames()
        if os.path.isdir(file_name + "_files"):
            pass
        else:
            os.mkdir(file_name + "_files")
        # 由于解压后是许多文件,预先建立同名文件夹
        for name in names:
            tar.extract(name, file_name + "_files/")
        tar.close()
    
    
    if __name__ == '__main__':
        make_targz('test.tar.gz', "E:python_samplelibs")
        make_targz_one_by_one('test01.tgz', "E:python_samplelibs")
        un_gz("test.tar.gz")
        un_tar("test.tar")
    
    # 弹窗
    # 先安装win32api模块:pip install pywin32
    import win32api
    import win32con
    
    info = '弹窗'
    print(info)
    win32api.MessageBox(None, info, "提示", win32con.MB_OK)
    
    • 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
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278
    • 279
    • 280
    • 281
    • 282
    • 283
    • 284
    • 285
    • 286
    • 287
    • 288
    • 289
    • 290
    • 291
    • 292
    • 293
    • 294
    • 295
    • 296
    • 297
    • 298
    • 299
    • 300
    • 301
    • 302
    • 303
    • 304
    • 305
    • 306
    • 307
    • 308
    • 309
    • 310
    • 311
    • 312
    • 313
    • 314
    • 315
    • 316
    • 317
    • 318
    • 319
    • 320
    • 321
    • 322
    • 323
    • 324
    • 325
    • 326
    • 327
    • 328
    • 329
    • 330
    • 331
    • 332
    • 333
    • 334
    • 335
    • 336
    • 337
    • 338
    • 339
    • 340
    • 341
    • 342
    • 343
    • 344
    • 345
    • 346
    • 347
    • 348
    • 349
    • 350
    • 351
    • 352
    • 353
    • 354
    • 355
    • 356
    • 357
    • 358
    • 359
    • 360
    • 361
    • 362
    • 363
    • 364
    • 365
    • 366
    • 367
    • 368
    • 369
    • 370
    • 371
    • 372
    • 373
    • 374
    • 375
    • 376
    • 377
    • 378
    • 379
    • 380
    • 381
    • 382
    • 383
    • 384
    • 385
    • 386
    • 387
    • 388
    • 389
    • 390
    • 391
    • 392
    • 393
    • 394
    • 395
    • 396
    • 397
    • 398
    • 399
    • 400
    • 401
    • 402
    • 403
    • 404
    • 405
    • 406
    • 407
    • 408
    • 409
    • 410
    • 411
    • 412
    • 413
    • 414
    • 415
    • 416
    • 417
    • 418
    • 419
    • 420
    • 421
    • 422
    • 423
    • 424
    • 425
    • 426
    • 427
    • 428
    • 429
    • 430
    • 431
    • 432
    • 433
    • 434
    • 435
    • 436
    • 437
    • 438
    • 439
    • 440
    • 441
    • 442
    • 443
    • 444
    • 445
    • 446
    • 447
    • 448
    • 449
    • 450
    • 451
    • 452
    • 453
    • 454
    • 455
    • 456
    • 457
    • 458
    • 459
    • 460
    • 461
    • 462
    • 463
    • 464
    • 465
    • 466
    • 467
    • 468
    • 469
    • 470
    • 471
    • 472
    • 473
    • 474
    • 475
    • 476
    • 477
    • 478
    • 479
    • 480
    • 481
    • 482
    • 483
    • 484
    • 485
    • 486
    • 487
    • 488
    • 489
    • 490
    • 491
    • 492
    • 493
    • 494
    • 495
    • 496
    • 497
    • 498
    • 499
    • 500
    • 501
    • 502
    • 503
    • 504
    • 505
    • 506
    • 507
    • 508
    • 509
    • 510
    • 511
    • 512
    • 513
    • 514
    • 515
    • 516
    • 517
    • 518
    • 519
    • 520
    • 521
    • 522
    • 523
    • 524
    • 525
    • 526
    • 527
    • 528
    • 529
    • 530
    • 531
    • 532
    • 533
    • 534
    • 535
    • 536
    • 537
    • 538
    • 539
    • 540
    • 541
    • 542
    • 543
    • 544
    • 545
    • 546
    • 547
    • 548
    • 549
    • 550
    • 551
    • 552
    • 553
    • 554
    • 555
    • 556
    • 557
    • 558
    • 559
    • 560
    • 561
    • 562
    • 563
    • 564
    • 565
    • 566
    • 567
    • 568
    • 569
    • 570
    • 571
    • 572
    • 573
    • 574
    • 575
    • 576
    • 577
    • 578
    • 579
    • 580
    • 581
    • 582
    • 583
    • 584
    • 585
    • 586
    • 587
    • 588
    • 589
    • 590
    • 591
    • 592
    • 593
    • 594
    • 595
    • 596
    • 597
    • 598
    • 599
    • 600
    • 601
    • 602
    • 603
    • 604
    • 605
    • 606
    • 607
    • 608
    • 609
    • 610
    • 611
    • 612
    • 613
    • 614
    • 615
    • 616
    • 617
    • 618
    • 619
    • 620
    • 621
    • 622
    • 623
    • 624
    • 625
    • 626
    • 627
    • 628
    • 629
    • 630
    • 631
    • 632
    • 633
    • 634
    • 635
    • 636
    • 637
    • 638
    • 639
    • 640
    • 641
    • 642
    • 643
    • 644
    • 645
    • 646
    • 647
    • 648
    • 649
    • 650
    • 651
    • 652
    • 653
    • 654
    • 655
    • 656
    • 657
    • 658
    • 659
    • 660
    • 661
    • 662
    • 663
    • 664
    • 665
    • 666
    • 667
    • 668
    • 669
    • 670
    • 671
    • 672
    • 673
    • 674
    • 675
    • 676
    • 677
    • 678
    • 679
    • 680
    • 681
    • 682
    • 683
    • 684
    • 685
    • 686
    • 687
    • 688
    • 689
    • 690
    • 691
    • 692
    • 693
    • 694
    • 695
    • 696
    • 697
    • 698
    • 699
    • 700
    • 701
    • 702
    • 703
  • 相关阅读:
    关于Java代码如何项目部署
    C#将图片转换为ICON格式(程序运行图标)
    Java连接PostGreSql
    docker desktop 点击setting 一直转圈圈
    echarts使用custom类型绘制矩形
    MERLIN-AToolfor Multi-party Privacy-preserving Record Linkage论文总结
    JRUY-G3交流三相电压继电器
    ES 2024 新特性
    Ajax、Fetch、Axios三者的区别
    docker常见命令
  • 原文地址:https://blog.csdn.net/south_d/article/details/134031497