[4]python+selenium - UI自动框架之封装基类BasePage页面

这部分内容是页面上的一些基本操作

from selenium.common.exceptions import TimeoutException, NoSuchElementException, WebDriverException, \
    StaleElementReferenceException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ActionChains
from common.KeyActions import *
from common.errors import StopTestCaseException, KTEC_WebDriverException
from selenium.webdriver.support.select import Select
from common.elementFinder import ElementFinder
from selenium.webdriver.common.keys import Keys
from common.log import *
import os, win32gui, win32con, time
from common.publicFunc import *

class BasePage(ElementFinder):
    """
    Second encapsulation based on Selenium
    """

    #
    # def __init__(self, driver):
    #     self.driver = drive

    def open(self, url):
        """ Open url, browser maximization"""
        self.driver.get(url)
        self.driver.maximize_window()

    def get_url(self):
        url = self.driver.current_url
        return url

    def open_tap(self, url):
        """open a new browser tap"""
        old_handles = self.get_window_handles()
        simulateKey('ctrl', 't')
        time.sleep(5)
        for _ in range(5):
            if len(self.get_window_handles()) > len(old_handles):
                break
            else:
                time.sleep(2)
        self.switch_to_window(self.get_window_handles()[len(old_handles)])
        self.driver.get(url)

    def close_tap(self):
        """close browser tap"""
        self.driver.close()

    def close_browser(self):
        """close browser"""
        self.driver.quit()

    def go_back(self):
        """go back"""
        self.driver.back()

    def refresh_(self):
        """refresh browser"""
        self.driver.refresh()

    def click(self, locator, isUpdated=False):
        """ click element"""
        # element = self.find_element_clickable(locator)
        element = self.find_element_clickable(locator)
        if not element:
            log.warning('[BS]_436:element{ele} not exist'.format(ele=locator))
            return
        for _ in range(2):
            log.info('[BS]_006:step --> click {ele} time={num}'.format(ele=locator, num=_ + 1))
            try:
                self.click_element(element)
                # if Mode().getBrowserType() is None or (Mode().getBrowserType() is not None and (Mode().getBrowserType()).lower()=='ie'):
                #     self.driver.execute_script("$(arguments[0]).click()", element)
                # else:
                #     self.click_element(element)
                break
            except KTEC_WebDriverException as e:
                log.warning('[BS]_434: click {ele} failed!,{info}'.format(ele=locator, info=e))
                time.sleep(1)
                element = self.find_element_clickable(locator)
            except Exception as e:
                log.warning('[BS]_444:click {ele},unknown error:{error}'.format(ele=locator, error=e))
                raise StopTestCaseException

    def right_click(self, driver, locator, isUpdated=False):
        """ click element"""
        time.sleep(1)
        # element = self.find_element_clickable(locator)
        element = self.find_element_clickable(locator)
        if not element:
            log.warning('[BS]_436:element{ele} not exist'.format(ele=locator))
            return
        for _ in range(2):
            log.info('[BS]_006:step --> click {ele} time={num}'.format(ele=locator, num=_ + 1))
            try:
                ActionChains(driver).context_click(element).perform()
                # if Mode().getBrowserType() is None or (Mode().getBrowserType() is not None and (Mode().getBrowserType()).lower()=='ie'):
                #     self.driver.execute_script("$(arguments[0]).click()", element)
                # else:
                #     self.click_element(element)
                break
            except KTEC_WebDriverException as e:
                log.warning('[BS]_434: click {ele} failed!,{info}'.format(ele=locator, info=e))
                time.sleep(1)
                element = self.find_element_clickable(locator)
            except Exception as e:
                log.warning('[BS]_444:click {ele},unknown error:{error}'.format(ele=locator, error=e))
                raise StopTestCaseException

    def click_element(self, element):
        log.info('[BS]_00601:step --> click_element')
        try:
            element.click()
            time.sleep(1)
        except StaleElementReferenceException:
            raise KTEC_WebDriverException('[BS]_element is not attached to the page document')
        except WebDriverException as e:
            raise KTEC_WebDriverException('[BS]_element would not receive the click!{error}'.format(error=e))
        except Exception as e:
            log.warning('[BS]_434:unknown error! {info}'.format(info=e))

    def click_by_coordinate(self, locator, xoffset=None, yoffset=None):
        '''click element by coordinate'''
        if xoffset is None or yoffset is None:
            element = self.find_element(locator)
            location = element.location
            xoffset = location['x']
            yoffset = location['y']
        ActionChains(self.driver).move_by_offset(xoffset, yoffset).click().perform()

    def input(self, locator, value, isClear=True):
        """ input text """
        if value is None: return
        element = self.find_element_clickable(locator, timeout=3)
        if not element: return
        if isClear:
            element.clear()
        element.send_keys(value)

    def scroll_element_into_view(self, locator):
        """Scrolls the element identified by ``locator`` into view."""
        element = self.find_element(locator)
        # Try/except can be removed when minimum required Selenium is 4.0 or greater.
        try:
            ActionChains(self.driver).move_to_element(element).perform()
        except AttributeError:
            log.warning('[BS]_Workaround for Selenium 3 bug.')
            element = element.wrapped_element
            ActionChains(self.driver).move_to_element(element).perform()

    def drag_and_drop(self, locator, target):
        """Drags the element identified by ``locator`` into the ``target`` element.

        The ``locator`` argument is the locator of the dragged element
        and the ``target`` is the locator of the target. See the
        `Locating elements` section for details about the locator syntax.

        Example:
        | `drag_and_drop(('css':'div#element'),('css':'div.target'))
        """
        element = self.find_element(locator)
        target = self.find_element(target)
        action = ActionChains(self.driver)
        action.click_and_hold(element)
        action.drag_and_drop(element, target).perform()

    def drag_and_drop_offset(self, locator, xoffset, yoffset):
        """Drags the element identified by ``locator`` into the ``target`` element.

        The ``locator`` argument is the locator of the dragged element
        and the ``target`` is the locator of the target. See the
        `Locating elements` section for details about the locator syntax.

        Example:
        | `drag_and_drop(('css':'div#element'),('css':'div.target'))
        """
        element = self.find_element(locator)
        action = ActionChains(self.driver)
        action.click_and_hold(element)
        action.drag_and_drop_by_offset(element, xoffset, yoffset).perform()

    def select_frame(self, locator):
        """Sets frame identified by ``locator`` as the current frame.

        See the `Locating elements` section for details about the locator
        syntax.

        Works both with frames and iframes. Use `Unselect Frame` to cancel
        the frame selection and return to the main frame.
        """
        log.info("[BS]_Selecting frame '%s'." % locator[1])
        element = self.find_element(locator)
        self.driver.switch_to.frame(element)

    def unselect_frame(self):
        """Sets the main frame as the current frame.

        In practice cancels the previous `Select Frame` call.
        """
        self.driver.switch_to.default_content()

    @property
    def current_url(self):
        return self.driver.current_url

    def wait_until_element_located_not_contains_text(self, locator, expectText, timeout=6, interval=0.5):
        """
        Determine whether the text in the element is not equal to the expected text
        :param expectText: expected text
        :return: the actual text
        """
        try:
            WebDriverWait(self.driver, timeout, interval) \
                .until_not(EC.text_to_be_present_in_element(locator, expectText))
            current_text = self.find_element_visible(locator).text
            return True, current_text
        except TimeoutException:
            return False, expectText

    def wait_until_element_located_contains_text(self, locator, expectText, timeout=6, interval=0.5):
        """
        Determine whether the text in the element is equal to the expected text
        :param expectText: expected text
        :return : the actual text
        """

        try:
            WebDriverWait(self.driver, timeout, interval) \
                .until(EC.text_to_be_present_in_element(locator, expectText))
            return True, expectText
        except TimeoutException:
            try:
                current_text = self.find_element_visible(locator).text
            except TimeoutException:
                log.warning('[BS]_431:%s not find!' % str(locator))
            else:
                return False, current_text

    def is_Element_Exist(self, locator, timeout=10, interval=0.5):
        try:
            WebDriverWait(self.driver, timeout, interval) \
                .until(EC.visibility_of_element_located(locator))
            return True
        except Exception:
            return False

    def get_page_source(self):
        return self.driver.page_source

    def get_cookies(self):
        """ get browser's cookies """
        return self.driver.get_cookies()

    def move_to_element(self, locator):
        """ Mouse over a visible element """
        element = self.find_element_visible(locator)
        ActionChains(self.driver).move_to_element(element).perform()

    def execute_script(self, js_command):
        """execute javascript"""
        try:
            self.driver.execute_script(js_command)
        except Exception as e:
            log.warning('[BS] excute failed %s' % e)

    def switch_to_alert_and_confirm(self):
        """switch to alert window"""
        self.driver.switch_to_alert().accept()

    def select_item_by_value(self, locator, value):
        log.info('[BS]_006:step --> select_item_by_value {ele},value={text}'.format(ele=locator, text=value))
        try:
            element = self.find_element_visible(locator)
            Select(element).select_by_value(value)
        except NoSuchElementException:
            log.warning('[BS]_433:%s not in select' % value)

    def select_item_by_index(self, locator, index):
        log.info('[BS]_006:step --> select_item_by_index {ele},index={text}'.format(ele=locator, text=index))
        try:
            element = self.find_element_visible(locator)
            Select(element).select_by_index(index)
        except NoSuchElementException as e:
            log.warning('[BS]_433:%s not in select' % index)

    def select_item_by_visible_text(self, locator, text):
        log.info('[BS]_006:step --> select_item_by_visible_text {ele},text={text}'.format(ele=locator, text=text))
        try:
            element = self.find_element_visible(locator)
            Select(element).select_by_visible_text(text)
        except NoSuchElementException:
            log.warning('[BS]_433:%s not in select' % text)

    def get_selected_item_text(self, locator):
        """Return the currently selected item of select element"""
        log.info('[BS]_006:step --> get_selected_item_text {ele}'.format(ele=locator))
        element = self.find_element(locator)
        try:
            selected_option = Select(element).first_selected_option
            return selected_option.text
        except TypeError:
            log.warning("[BS]_432:%s not find!" % str(locator))
        except NoSuchElementException:
            log.warning("[BS]_433:No options are selected in %s" % str(locator))

    def get_all_select_item(self, locator):
        """Returns all options in the select element"""
        for _ in range(2):
            log.info('[BS]_006:step --> get_all_select_item {ele}, time={num}'.format(ele=locator, num=_ + 1))
            try:
                element = self.find_element(locator)
                selected_options = Select(element).options
                if not selected_options:
                    break
                else:
                    for i in range(len(selected_options)):
                        selected_options[i] = selected_options[i].text
            except TypeError:
                log.warning("[BS]_432:%s not find!" % str(locator))
                break
            except StaleElementReferenceException:
                log.info(
                    '[BS]_00601:step --> element{ele} is not attached to the page document'.format(ele=locator))
                continue
        return selected_options

    def is_element_located_selected(self, locator):
        log.info('[BS]_006:step --> is_element_located_selected {ele}'.format(ele=locator))
        try:
            element = self.find_element_visible(locator)
            element.is_selected()
            return True
        except TimeoutException:
            log.warning('[BS]_431:%s not find!' % str(locator))
            return False

    def get_elements_value(self, locator, timeout=6, interval=0.5):
        """
        Returns the text value of multiple elements in the list variable
        """
        for _ in range(2):
            log.info('[BS]_006:step --> get_elements_text {ele}, time={num}'.format(ele=locator, num=_ + 1))
            result = []
            try:
                elements = self.find_elements(locator, timeout, interval)
                if elements is not None:
                    for ele in elements:
                        result.append(ele.text)
                return result
            except AttributeError:
                log.warning('[BS]_431:%s not find!' % str(locator))
                break
            except StaleElementReferenceException:
                log.info(
                    '[BS]_00601:step --> elements{ele} is not attached to the page document'.format(ele=locator))
                time.sleep(1)
                continue

    def get_element_text(self, locator, timeout=6, interval=0.5):
        """ Return the text value of the element"""
        for _ in range(2):
            log.info('[BS]_006:step --> get_element_text {ele}, time={num}'.format(ele=locator, num=_ + 1))
            try:
                element = self.find_element(locator, timeout, interval)
                return element.text
            except AttributeError:
                log.warning('[BS]_431:%s not find!' % str(locator))
                break
            except StaleElementReferenceException:
                log.info(
                    '[BS]_00601:step --> element{ele} is not attached to the page document'.format(ele=locator))
                time.sleep(1)
                continue

    def get_element_Attribute_value(self, locator, attribute, timeout=6, interval=0.5):
        """
        Get an attribute value of an element
        For example:
        get_element_Attribute_value(locator=('id','xxx'),attribute='class')
        """
        for _ in range(2):
            log.info(
                '[BS]_006:step --> get_element_Attribute_value {ele}, time={num}'.format(ele=locator, num=_ + 1))
            try:
                element = self.find_element(locator, timeout, interval)
                try:
                    attributeValue = element.get_attribute(attribute)
                    return attributeValue
                except Exception as e:
                    log.warning(
                        '431:can not get attribute [%s] value and error message is %s !' % (str(attribute), str(e)))
                    break
            except AttributeError:
                log.warning('[BS]_431:%s not find!' % str(locator))
                break
            except StaleElementReferenceException:
                log.info(
                    '[BS]_00601:step --> element{ele} is not attached to the page document'.format(ele=locator))
                time.sleep(1)
                continue

    def checkbox_is_selected(self, locator, timeout=3, interval=0.5):
        """get whether checkbox is selected"""
        log.info('[BS]_006:step --> checkbox_is_selected {ele}'.format(ele=locator))
        try:
            WebDriverWait(self.driver, timeout, interval) \
                .until(EC.element_located_to_be_selected(locator))
            return True
        except TimeoutException:
            return False

    def checkbox_is_not_selected(self, locator, timeout=3, interval=0.5):
        """get whether checkbox is not selected"""
        log.info('[BS]_006:step --> checkbox_is_not_selected {ele}'.format(ele=locator))
        try:
            WebDriverWait(self.driver, timeout, interval) \
                .until_not(EC.element_located_to_be_selected(locator))
            return True
        except TimeoutException:
            return False

    def is_visible(self, locator, timeout=1, interval=0.5):
        """ Judge whether the element is visible """
        log.info('[BS]_006:step --> is_visible {ele}'.format(ele=locator))
        try:
            WebDriverWait(self.driver, timeout, interval).until(EC.visibility_of_element_located(locator))
            isdisplay = True
        except TimeoutException:
            isdisplay = False
        return isdisplay

    def is_clickable(self, locator, timeout=1, interval=0.5):
        """ Judge whether the element is visible """
        log.info('[BS]_006:step --> is_clickable {ele}'.format(ele=locator))
        try:
            WebDriverWait(self.driver, timeout, interval).until(EC.element_to_be_clickable(locator))
            isdisplay = True
        except TimeoutException:
            isdisplay = False
        return isdisplay

    def is_enable(self, locator):
        log.info('[BS]_006:step --> is_enable {ele}'.format(ele=locator))
        try:
            result = self.find_element(locator).is_enabled()
        except TypeError:
            return None
        return result

    def dismiss_alert(self):
        """dismiss alert"""
        self.driver.switch_to_alert().dismiss()

    def accept_alert(self):
        """Accept alert"""
        self.driver.switch_to_alert().accept()

    def curr_window_handle(self):
        """Get current window handle"""
        handle = self.driver.current_window_handle
        return handle

    def get_window_handles(self):
        """Get handles of all currently open windows"""
        handles = self.driver.window_handles
        return handles

    def switch_to_window(self, handle):
        """switch to window"""
        self.driver.switch_to.window(handle)

    def sendSpace(self, locator):
        """Enter SAPCE in the current element"""
        self.sendKeys(locator, Keys.SPACE)

    def sendEnter(self, locator):
        """Enter ENTER in the current element"""
        self.sendKeys(locator, Keys.ENTER)

    def sendFile(self, locator, path):
        element = self.find_element(locator)
        element.send_keys(path)

    def take_screenshot(self, screen_dir, fileName=None):
        '''
        screenshot
        For example:
        take_screenshot(screen_dir="C:\\forder",fileName="screenshot.png")
        '''
        rq = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))

        if fileName is None:
            fileName = rq
        else:
            fileName = fileName + "_" + rq

        file_extension = fileName.rsplit(".", 1)
        if len(file_extension) == 2:
            if not file_extension[1].lower() in ['png', 'jpg', 'jpeg']:
                fileName = fileName + '.png'
        else:
            fileName = fileName + '.png'

        screen_name = os.path.join(screen_dir, fileName)
        try:
            self.driver.get_screenshot_as_file(screen_name)
            log.info("[BS]_Had take screenshot and saved!")
        except Exception as e:
            log.error("[BS]_Failed to take screenshot!", format(e))

    def upload_file(self, locator, filepath):
        self.click(locator)
        try:
            if filepath is not None:
                try:
                    dialog = win32gui.FindWindow('#32770', 'Open')  # 对话框
                    ComboBoxEx32 = win32gui.FindWindowEx(dialog, 0, "ComboBoxEx32", None)
                    ComboBox = win32gui.FindWindowEx(ComboBoxEx32, 0, "ComboBox", None)
                    edit = win32gui.FindWindowEx(ComboBox, 0, 'Edit', None)  # 上面三句依次寻找对象,直到找到输入框Edit对象的句柄
                    button = win32gui.FindWindowEx(dialog, 0, 'Button', None)  # 确定按钮Button
                    win32gui.SendMessage(edit, win32con.WM_SETTEXT, None, filepath)  # 往输入框输入绝对地址
                    win32gui.SendMessage(dialog, win32con.WM_COMMAND, 1, button)  # 按button
                except Exception as e:
                    log.error("[BS]_Failed to upload fileFormat!", format(e))
        except Exception as e:
            log.error(("[BS]_filepath is empty!", format(e)))

    def reset_Attribute(self, locator, attribute, value):
        try:
            element = self.find_element(locator)
            self.driver.execute_script("arguments[0].setAttribute(arguments[1],arguments[2])", element, attribute,
                                       value)
        except Exception as e:
            log.error(("[BS]_attribute is not found!", format(e)))

    def wait_until_disappear(self, locator, waitTime=5):
        name = get_variable_name(locator)
        for _ in range(5):
            if self.is_visible(locator, waitTime):
                time.sleep(waitTime)
                log.info("waiting %s disappear" % name)
            else:
                log.info("waited %s disappear" % name)
                break

    def wait_element_visible(self, locator, waitTime=2):
        for _ in range(5):
            if self.is_visible(locator, waitTime):
                break
            else:
                time.sleep(waitTime)
                log.info("[BS]_wait element is visible")

    def get_AttributeValue(self, locator, attribute):
        try:
            element = self.find_element(locator)
            value = element.get_addribute(attribute)
            return value
        except Exception as e:
            log.error(("[BS]_locator is not found!", format(e)))



if __name__ == "__main__":
    '''self test'''

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/761624.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

第2章-Python编程基础

#本章目标 1,了解什么是计算机程序 2,了解什么是编程语言 3,了解编程语言的分类 4,了解静态语言与脚本语言的区别 5,掌握IPO程序编写方法 6,熟练应用输出函数print与输入函数input 7,掌握Python…

泛型的使用(<T>)

文章目录 前言一、泛型是什么?二、泛型的使用 1.定义泛型类2.泛型的常规用法总结 前言 强制类型转换存在一定隐患,如数据丢失、内存溢出、运行时错误、程序逻辑错误等。所以提供了泛型机制,使程序员可以定义安全的数据类型进行操作。通俗的理…

【postgresql】 基础知识学习

PostgreSQL是一个高度可扩展的开源对象关系型数据库管理系统(ORDBMS),它以其强大的功能、灵活性和可靠性而闻名。 官网地址:https://www.postgresql.org/ 中文社区:文档目录/Document Index: 世界上功能最强大的开源…

GP37-S-N、GP37-S-E、GP37-S-R比例电磁铁驱动放大器

比例阀用电磁铁EP45-C、EP37-E、EP45-G、EP45-N、GP37-3-A、GP37-S-N、GP37-S-E、GP37-S-R在直流12V/24V的电液比例控制系统中与BEUEC比例控制放大器配套使用,共同作用于比例阀的控制。电磁铁输出力通过负载弹簧转换成位移,实现电流-力-位移线性转换&…

嵌入式问题分析思路

BUG解决总体思路: 1.1 定位bug范围及性质 要有效解决问题,首先要缩小范围,集中关注最近的代码变化。这有助于迅速定位可能引入问题的部分,避免无谓的时间浪费。检查最近的代码提交记录和修改日志,找出可能影响现有功能的变更。然…

减肥期间三餐饮食搭配

减肥期间三餐饮食搭配 早起洗漱后早餐前:一杯温水大口喝下,清洁肠道!!! 减肥期间早餐搭配 早餐9点前完成✅ ❤必须喝(纯牛奶、无糖豆浆、无糖酸奶、黑咖啡都可以,四选一) ❤必须吃1~2个鸡蛋 (蒸,煮,煎,炒都可以) ❤必须吃主食 (红薯、玉米、南瓜、紫薯、山药…

基于单片机的 LED 照明灯智能调光系统设计

摘  要: 社会经济的不断发展,推动了智能化生活的进程,智能调光技术开始广泛应用在生活中,人们也逐渐提高了灯光亮灯率等的要求。基于此,笔者主要设计了基于单片机的 LED 照明灯智能调光系统,希望能够为相关…

小程序的运行机制、更新机制、生命周期介绍保姆级教程全解

一、小程序运行机制 1. 小程序冷启动 小程序启动可以分为两种情况,一种是冷启动,一种是热启动- 冷启动:如果用户首次打开,或小程序销毁后被用户再次打开,此时小程序需要重新加载启动- 热启动:如果用户已经打…

植物大战僵尸杂交版手机下载与安装全攻略

植物大战僵尸杂交版是一款深受玩家喜爱的策略冒险游戏,以其丰富的植物种类、多样的关卡设计和趣味的玩法著称。本文将为您提供详细的下载与安装教程,帮助您快速上手,享受游戏带来的乐趣。 游戏简介 植物大战僵尸杂交版在传统玩法的基础上&a…

使用React复刻ThreeJS官网示例——keyframes动画

最近在看three.js相关的东西,想着学习一下threejs给的examples。源码是用html结合js写的,恰好最近也在学习react,就用react框架学习一下。 本文参考的是threeJs给的第一个示例 three.js examples (threejs.org) 一、下载threeJS源码 通常我们…

视频监控业务平台LntonCVS国标视频综合管理平台功能及技术优势

随着安防行业的快速进步,传统的视频监控平台正在与先进的技术和互联网技术融合,包括5G通信、GIS、大数据、云计算、边缘计算、AI识别、智能分析和视频直播等。这些技术的整合形成了综合性视频监控管理平台,具备集中管理、多级联网共享、互联互…

中霖教育怎么样?税务师通过率高吗?

中霖教育怎么样?税务师通过率高吗? 我们在税务师考试培训方面有着不错的成绩,这都是老师与学员共同努力的结果。 采用小班教学模式,确保每位学员都能得到足够的关注和指导,在学习过程中针对学员的薄弱环节进行专项突破。 因为大部分学员…

Soul探索未来智能互动模式,人机交互重塑社交元宇宙体验

在当今快速发展的科技领域中,人机交互已成为一个备受关注的话题。随着人工智能和机器学习技术的不断进步,人们与计算机和智能设备之间的互动方式正在发生翻天覆地的变化。这种交互不止局限于键盘和鼠标,更涵盖了语音识别、手势控制、虚拟现实等多种形式。人机交互的创新不仅提高…

什么样的网工才是有前途的?

最近整个就业市场的变化,搞得人心惶惶。 可能很多朋友都在思考这样一个问题:现在做网工还有前途吗?什么样的网工才是有前途的?考HCIE认证还来得及吗? 作为网络工程师,该如何确保自己的职业发展方向正确&a…

Linux[高级管理]——Squid代理服务器的部署和应用(反向代理详解)

🏡作者主页:点击! 👨‍💻Linux高级管理专栏:点击! ⏰️创作时间:2024年6月24日11点11分 🀄️文章质量:95分 目录 ————前言———— Squid的几种模式…

咖啡消费旺季到来 为何想转让的库迪联营商却越来越多

文 | 智能相对论 作者 | 霖霖 去年还在朝“三年万店”计划狂奔的库迪,今年已出现明显“失速”。 早在今年2月,库迪就官宣其门店数已超过7000家,如今4个多月过去,据极海品牌监测数据显示,截至6月27日,其总…

数据库断言-数据库连接池

原因:现在的代码是单线程,如果遇到大并发的话就会崩溃,数据库查询就查不过来 措施:需要建立数据库连接池,可以设置连接池的数量 什么是大并发:很多客户端在idea写的程序和数据库建立连接 步骤&#xff1…

C++中的类型转换操作符:static_cast reinterpret_cast const_cast dynamic_cast

目录​​​​​​​ C语言中的类型转换 C中的类型转换 C中的类型转换操作符 static_cast reinterpret_cast const_cast volatile关键字 赋值兼容 dynamic_cast C语言中的类型转换 基本概念:赋值运算符左右两侧类型不同,或形参与实参类型不匹配…

数学知识——欧拉函数

数学知识(二) 20240628 求和N互质的个数公式 先分解N,再求个数fai n欧拉函数的证明:用容斥原理 不考 求质因子 p1, … , pk 1-N中与N互质的个数, 去掉质因子倍数 是pi的倍数的有N/pi个,但是会有既是p1也是…

计算机人说学校-南京大学-计算机方向

1. 专长、特点与特色 南京大学计算机专业在国内外享有很高的声誉,其专长、特点和特色主要体现在以下几个方面: 理论性强:重视数学、逻辑、数据结构、算法、电子设计、计算机体系结构和系统软件等方面的理论基础和专业技术基础。实践性强&am…