Python 小型项目大全 56~60

news2024/10/6 18:33:12

五十六、质数

原文:http://inventwithpython.com/bigbookpython/project56.html

质数是只能被 1 和它自己整除的数。质数有各种各样的实际应用,但是没有算法可以预测它们;我们必须一次计算一个。然而,我们知道有无限多的质数有待发现。

这个程序通过强力计算找到质数。它的代码类似于项目 24,“因子寻找器。”(另一种描述质数的方式是,一和数本身是它唯一的因子。)你可以从en.wikipedia.org/wiki/Prime_number那里找到更多关于质数的信息。

运行示例

当您运行primenumbers.py时,输出将如下所示:

Prime Numbers, by Al Sweigart email@protected
`--snip--`
Enter a number to start searching for primes from:
(Try 0 or 1000000000000 (12 zeros) or another number.)
> 0
Press Ctrl-C at any time to quit. Press Enter to begin...
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, `--snip--`

工作原理

isPrime()函数接受一个整数,如果它是质数,则返回True。否则,它返回False。如果你想了解这个项目,项目 24 是值得研究的。isPrime()函数本质上是寻找给定数字中的任何因子,如果找到任何因子,就返回False

这个程序中的算法可以快速找到大质数。一万亿这个数字只有 10 位数。但是要找到像古戈尔一样大的质数(一个 1 后面跟着 100 个 0),你需要使用一种高级算法,比如 Rabin-Miller 素性测试。我的书《Python 密码破解指南》第 22 章有这个算法的 Python 实现。

"""Prime Numbers, by Al Sweigart email@protected
Calculates prime numbers, which are numbers that are only evenly
divisible by one and themselves. They are used in a variety of practical
applications.
More info at: https://en.wikipedia.org/wiki/Prime_number
This code is available at https://nostarch.com/big-book-small-python-programming
Tags: tiny, math, scrolling"""

import math, sys

def main():
    print('Prime Numbers, by Al Sweigart email@protected')
    print('Prime numbers are numbers that are only evenly divisible by')
    print('one and themselves. They are used in a variety of practical')
    print('applications, but cannot be predicted. They must be')
    print('calculated one at a time.')
    print()
    while True:
        print('Enter a number to start searching for primes from:')
        print('(Try 0 or 1000000000000 (12 zeros) or another number.)')
        response = input('> ')
        if response.isdecimal():
            num = int(response)
            break

    input('Press Ctrl-C at any time to quit. Press Enter to begin...')

    while True:
        # Print out any prime numbers:
        if isPrime(num):
            print(str(num) + ', ', end='', flush=True)
        num = num + 1  # Go to the next number.


def isPrime(number):
    """Returns True if number is prime, otherwise returns False."""
    # Handle special cases:
    if number < 2:
        return False
    elif number == 2:
        return True

    # Try to evenly divide number by all numbers from 2 up to number's
    # square root.
    for i in range(2, int(math.sqrt(number)) + 1):
        if number % i == 0:
            return False
    return True


# If this program was run (instead of imported), run the game:
if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        sys.exit()  # When Ctrl-C is pressed, end the program. 

探索程序

试着找出下列问题的答案。尝试对代码进行一些修改,然后重新运行程序,看看这些修改有什么影响。

  1. 如果将第 22 行的response.isdecimal()改为response,并输入一个非数字作为开始搜索质数的数字,会出现什么错误?
  2. 如果把第 38 行的number < 2改成number > 2会怎么样?
  3. 如果把第 46 行的number % 1 == 0改成number % i != 0会怎么样?

五十七、进度条

原文:http://inventwithpython.com/bigbookpython/project57.html

一个进度条是一个视觉元素,显示任务已经完成了多少。进度条通常与下载文件或软件安装一起使用。这个项目创建了一个getProgressBar()函数,它根据传递给它的参数返回一个进度条字符串。它模拟了一个下载文件,但是你可以在你自己的项目中重复使用进度条。

运行示例

当您运行progressbar.py时,输出将如下所示:

Progress Bar Simulation, by Al Sweigart
[█████████                               ] 24.6% 1007/4098

工作原理

进度条依赖于在终端窗口中运行的程序可以执行的某种技巧。正如'\n''\t'分别是换行符和制表符的转义符一样,'\b'是退格字符的转义符。如果您“打印”一个退格字符,文本光标将向左移动,并擦除先前打印的字符。这只适用于文本光标所在的当前行。如果运行代码print('Hello\b\b\b\b\bHowdy'),Python 将打印文本"Hello",将文本光标向后移动五格,然后打印文本HowdyHowdy文本将覆盖Hello,让它看起来像是你直接打印了Hello

我们可以使用这种技术,通过打印一个版本的进度条,将文本光标移回起点,然后打印一个更新的进度条,在一行中创建一个动画进度条。这种效果可以生成任何文本动画,而不需要像bext这样的模块,尽管它将被限制在终端窗口中占据一行。

一旦创建了这个程序,就可以通过运行import progressbar并打印从progressbar.getProgressBar()返回的字符串,在其他 Python 程序中显示进度条。

"""Progress Bar Simulation, by Al Sweigart email@protected
A sample progress bar animation that can be used in other programs.
This code is available at https://nostarch.com/big-book-small-python-programming
Tags: tiny, module"""

import random, time

BAR = chr(9608) # Character 9608 is '█'

def main():
    # Simulate a download:
    print('Progress Bar Simulation, by Al Sweigart')
    bytesDownloaded = 0
    downloadSize = 4096
    while bytesDownloaded < downloadSize:
        # "Download" a random amount of "bytes":
        bytesDownloaded += random.randint(0, 100)

        # Get the progress bar string for this amount of progress:
        barStr = getProgressBar(bytesDownloaded, downloadSize)

        # Don't print a newline at the end, and immediately flush the
        # printed string to the screen:
        print(barStr, end='', flush=True)

        time.sleep(0.2)  # Pause for a little bit:

        # Print backspaces to move the text cursor to the line's start:
        print('\b' * len(barStr), end='', flush=True)


def getProgressBar(progress, total, barWidth=40):
    """Returns a string that represents a progress bar that has barWidth
    bars and has progressed progress amount out of a total amount."""

    progressBar = ''  # The progress bar will be a string value.
    progressBar += '['  # Create the left end of the progress bar.

    # Make sure that the amount of progress is between 0 and total:
    if progress > total:
        progress = total
    if progress < 0:
        progress = 0

    # Calculate the number of "bars" to display:
    numberOfBars = int((progress / total) * barWidth)

    progressBar += BAR * numberOfBars  # Add the progress bar.
    progressBar += ' ' * (barWidth - numberOfBars)  # Add empty space.
    progressBar += ']'  # Add the right end of the progress bar.

    # Calculate the percentage complete:
    percentComplete = round(progress / total * 100, 1)
    progressBar += ' ' + str(percentComplete) + '%'  # Add percentage.

    # Add the numbers:
    progressBar += ' ' + str(progress) + '/' + str(total)

    return progressBar  # Return the progress bar string.


# If the program is run (instead of imported), run the game:
if __name__ == '__main__':
    main() 

在输入源代码并运行几次之后,尝试对其进行实验性的修改。你也可以自己想办法做到以下几点:

  • 创建一个旋转器的单行动画,它在角色|/-\之间交替,以产生旋转效果。
  • 创建一个程序,可以显示从左向右移动的文本滚动字幕。
  • 创建一个单行动画,显示一组四个等号作为一个单元来回移动,类似于电视节目霹雳游侠中机器人车上的红色扫描灯或电视节目太空堡垒卡拉狄加中的赛昂机器人脸。

探索程序

试着找出下列问题的答案。尝试对代码进行一些修改,然后重新运行程序,看看这些修改有什么影响。

  1. 如果删除或注释掉第 29 行的print('\b' * len(barStr), end='', flush=True)会发生什么?
  2. 如果把第 48 行和第 49 行的顺序对调会怎么样?
  3. 如果把 53 行的round(progress / total * 100, 1)改成round(progress / total * 100)会怎么样?

五十八、彩虹

原文:http://inventwithpython.com/bigbookpython/project58.html

彩虹是一个简单的程序,显示了一个彩色的彩虹在屏幕上来回移动。该程序利用了这样一个事实,即当新的文本行出现时,现有的文本会向上滚动,使其看起来像是在移动。这个项目对初学者来说很好,它类似于项目 15“深坑”

运行示例

图 58-1 显示了运行rainbow.py时的输出。

f58001

:彩虹的锯齿形输出,在屏幕上是彩色的

工作原理

这个程序连续打印相同的彩虹图案。改变的是打印在它左边的空格字符的数量。增加这个数字会使彩虹向右移动,减少这个数字会使彩虹向左移动。indent变量跟踪空格的数量。将indentIncreasing变量设置为True表示indent应该增加,直到到达60,此时变为False。代码的其余部分减少了空格的数量。一旦到达0,它又变回True,重复彩虹的之字形。

"""Rainbow, by Al Sweigart email@protected
Shows a simple rainbow animation. Press Ctrl-C to stop.
This code is available at https://nostarch.com/big-book-small-python-programming
Tags: tiny, artistic, bext, beginner, scrolling"""

import time, sys

try:
   import bext
except ImportError:
    print('This program requires the bext module, which you')
    print('can install by following the instructions at')
    print('https://pypi.org/project/Bext/')
    sys.exit()

print('Rainbow, by Al Sweigart email@protected')
print('Press Ctrl-C to stop.')
time.sleep(3)

indent = 0  # How many spaces to indent.
indentIncreasing = True  # Whether the indentation is increasing or not.

try:
    while True:  # Main program loop.
        print(' ' * indent, end='')
        bext.fg('red')
        print('##', end='')
        bext.fg('yellow')
        print('##', end='')
        bext.fg('green')
        print('##', end='')
        bext.fg('blue')
        print('##', end='')
        bext.fg('cyan')
        print('##', end='')
        bext.fg('purple')
        print('##')

        if indentIncreasing:
            # Increase the number of spaces:
            indent = indent + 1
            if indent == 60:  # (!) Change this to 10 or 30.
                # Change direction:
                indentIncreasing = False
        else:
            # Decrease the number of spaces:
            indent = indent - 1
            if indent == 0:
                # Change direction:
                indentIncreasing = True

        time.sleep(0.02)  # Add a slight pause.
except KeyboardInterrupt:
    sys.exit()  # When Ctrl-C is pressed, end the program. 

探索程序

试着找出下列问题的答案。尝试对代码进行一些修改,然后重新运行程序,看看这些修改有什么影响。

  1. 如果把第 44 行的False改成True会怎么样?
  2. 如果将所有bext.fg()调用的参数都改为'random',会发生什么?

五十九、石头剪刀布

原文:http://inventwithpython.com/bigbookpython/project59.html

在这个版本的双人手游中,玩家面对电脑。你可以选择石头、布或剪刀。石头打败剪刀,剪刀打败布,布打败石头。这个程序增加了一些短暂的停顿来制造悬念。

这个游戏的一个变种,见项目 60,“石头剪刀布(必胜版本)。”

运行示例

当您运行rockpaperscissors.py时,输出将如下所示:

Rock, Paper, Scissors, by Al Sweigart email@protected
- Rock beats scissors.
- Paper beats rocks.
- Scissors beats paper.

0 Wins, 0 Losses, 0 Ties
Enter your move: (R)ock (P)aper (S)cissors or (Q)uit
> r
ROCK versus...
1...
2...
3...
SCISSORS
You win!
1 Wins, 0 Losses, 0 Ties
Enter your move: (R)ock (P)aper (S)cissors or (Q)uit
`--snip--`

工作原理

石头剪刀布的游戏逻辑相当简单,我们在这里用if - elif语句实现它。为了增加一点悬念,第 45 至 51 行在揭示对手的移动之前倒计时,在计数之间有短暂的停顿。这给了玩家一段时间,让他们对游戏的结果感到兴奋。如果没有这种停顿,结果会在玩家开始移动时立即出现——有点虎头蛇尾。为玩家改善用户体验并不需要很多代码。

"""Rock, Paper, Scissors, by Al Sweigart email@protected
The classic hand game of luck.
This code is available at https://nostarch.com/big-book-small-python-programming
Tags: short, game"""

import random, time, sys

print('''Rock, Paper, Scissors, by Al Sweigart email@protected
- Rock beats scissors.
- Paper beats rocks.
- Scissors beats paper.
''')

# These variables keep track of the number of wins, losses, and ties.
wins = 0
losses = 0
ties = 0

while True:  # Main game loop.
    while True:  # Keep asking until player enters R, P, S, or Q.
        print('{} Wins, {} Losses, {} Ties'.format(wins, losses, ties))
        print('Enter your move: (R)ock (P)aper (S)cissors or (Q)uit')
        playerMove = input('> ').upper()
        if playerMove == 'Q':
            print('Thanks for playing!')
            sys.exit()

        if playerMove == 'R' or playerMove == 'P' or playerMove == 'S':
            break
        else:
            print('Type one of R, P, S, or Q.')

    # Display what the player chose:
    if playerMove == 'R':
        print('ROCK versus...')
        playerMove = 'ROCK'
    elif playerMove == 'P':
        print('PAPER versus...')
        playerMove = 'PAPER'
    elif playerMove == 'S':
        print('SCISSORS versus...')
        playerMove = 'SCISSORS'

    # Count to three with dramatic pauses:
    time.sleep(0.5)
    print('1...')
    time.sleep(0.25)
    print('2...')
    time.sleep(0.25)
    print('3...')
    time.sleep(0.25)

    # Display what the computer chose:
    randomNumber = random.randint(1, 3)
    if randomNumber == 1:
        computerMove = 'ROCK'
    elif randomNumber == 2:
        computerMove = 'PAPER'
    elif randomNumber == 3:
        computerMove = 'SCISSORS'
    print(computerMove)
    time.sleep(0.5)

    # Display and record the win/loss/tie:
    if playerMove == computerMove:
        print('It\'s a tie!')
        ties = ties + 1
    elif playerMove == 'ROCK' and computerMove == 'SCISSORS':
        print('You win!')
        wins = wins + 1
    elif playerMove == 'PAPER' and computerMove == 'ROCK':
        print('You win!')
        wins = wins + 1
    elif playerMove == 'SCISSORS' and computerMove == 'PAPER':
        print('You win!')
        wins = wins + 1
    elif playerMove == 'ROCK' and computerMove == 'PAPER':
        print('You lose!')
        losses = losses + 1
    elif playerMove == 'PAPER' and computerMove == 'SCISSORS':
        print('You lose!')
        losses = losses + 1
    elif playerMove == 'SCISSORS' and computerMove == 'ROCK':
        print('You lose!')
        losses = losses + 1 

在输入源代码并运行几次之后,尝试对其进行实验性的修改。你也可以自己想办法做到以下几点:

  • 在游戏中加入“蜥蜴”和“斯波克”的招式。蜥蜴毒死斯波克,吃纸,却被石头碾碎,被剪刀斩首。斯波克折断剪刀,蒸发岩石,但被蜥蜴毒死,被纸证明是错误的。
  • 允许玩家每次胜利赢得一分,每次失败失去一分。一旦获胜,玩家还可以承担“双倍或零”的风险,以可能在随后的回合中赢得 2、4、8、16 以及更多的点数。

探索程序

试着找出下列问题的答案。尝试对代码进行一些修改,然后重新运行程序,看看这些修改有什么影响。

  1. 如果将第 54 行的random.randint(1, 3)改为random.randint(1, 300),会得到什么错误?
  2. 如果把第 65 行的playerMove == computerMove改成True会怎么样?

六十、石头剪刀布(必胜版本)

原文:http://inventwithpython.com/bigbookpython/project60.html

石头剪刀布的变体与项目 59“石头剪刀布”相同,只是玩家总是赢。选择计算机招式的代码被设置为总是选择失败的招式。你可以把这个游戏提供给你的朋友,他们赢的时候可能会很兴奋。。。一开始。看看他们需要多长时间才能意识到游戏被操纵对他们有利。

运行示例

当您运行rockppapersscissorsalwayswin.py时,输出将如下所示:

Rock, Paper, Scissors, by Al Sweigart email@protected
- Rock beats scissors.
- Paper beats rocks.
- Scissors beats paper.

0 Wins, 0 Losses, 0 Ties
Enter your move: (R)ock (P)aper (S)cissors or (Q)uit
> p
PAPER versus...
1...
2...
3...
ROCK
You win!
1 Wins, 0 Losses, 0 Ties
Enter your move: (R)ock (P)aper (S)cissors or (Q)uit
> s
SCISSORS versus...
1...
2...
3...
PAPER
You win!
2 Wins, 0 Losses, 0 Ties
`--snip--`
SCISSORS versus...
1...
2...
3...
PAPER
You win!
413 Wins, 0 Losses, 0 Ties
Enter your move: (R)ock (P)aper (S)cissors or (Q)uit
`--snip--`

工作原理

你可能会注意到这个版本的程序比项目 59 要短。这是有意义的:当你不必为计算机随机生成一步棋并计算游戏的结果时,你可以从原始代码中删除相当多的代码。也没有变量来跟踪损失和平局的数量,因为无论如何这些都是零。

"""Rock,Paper, Scissors (Always Win version)
By Al Sweigart email@protected
The classic hand game of luck, except you always win.
This code is available at https://nostarch.com/big-book-small-python-programming
Tags: tiny, game, humor"""

import time, sys

print('''Rock, Paper, Scissors, by Al Sweigart email@protected
- Rock beats scissors.
- Paper beats rocks.
- Scissors beats paper.
''')

# These variables keep track of the number of wins.
wins = 0

while True:  # Main game loop.
    while True:  # Keep asking until player enters R, P, S, or Q.
        print('{} Wins, 0 Losses, 0 Ties'.format(wins))
        print('Enter your move: (R)ock (P)aper (S)cissors or (Q)uit')
        playerMove = input('> ').upper()
        if playerMove == 'Q':
            print('Thanks for playing!')
            sys.exit()

        if playerMove == 'R' or playerMove == 'P' or playerMove == 'S':
            break
        else:
            print('Type one of R, P, S, or Q.')

    # Display what the player chose:
    if playerMove == 'R':
        print('ROCK versus...')
    elif playerMove == 'P':
        print('PAPER versus...')
    elif playerMove == 'S':
        print('SCISSORS versus...')

    # Count to three with dramatic pauses:
    time.sleep(0.5)
    print('1...')
    time.sleep(0.25)
    print('2...')
    time.sleep(0.25)
    print('3...')
    time.sleep(0.25)

    # Display what the computer chose:
    if playerMove == 'R':
        print('SCISSORS')
    elif playerMove == 'P':
        print('ROCK')
    elif playerMove == 'S':
        print('PAPER')

    time.sleep(0.5)

    print('You win!')
    wins = wins + 1 

在输入源代码并运行几次之后,尝试对其进行实验性的修改。你也可以自己想办法做到以下几点:

  • 在游戏中加入“蜥蜴”和“斯波克”的招式。蜥蜴毒死斯波克,吃纸,却被石头碾碎,被剪刀斩首。斯波克折断剪刀,蒸发岩石,但被蜥蜴毒死,被纸证明是错误的。
  • 允许玩家每赢一次就赢得一分。一旦获胜,玩家还可以承担“双倍或零”的风险,以可能赢得 2、4、8、16 以及更多的点数。

探索程序

试着找出下列问题的答案。尝试对代码进行一些修改,然后重新运行程序,看看这些修改有什么影响。

  1. 如果删除或注释掉第 33 到 57 行会发生什么?
  2. 如果把第 22 行的input('> ').upper()改成input('> ')会怎么样?

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

技术招聘漫谈 | Java工程师招聘难?你可能需要这份独家指南

两周前&#xff0c;我们发布了一篇关于怎样招聘前端工程师的文章&#xff08;点击此处顾&#xff09;。在文章中&#xff0c;我们分析了前端岗位有哪些必不可少的考察要点&#xff0c;以及如何在面试中考核对方是否能写出高质量的代码&#xff0c;这篇文章得到了大量技术面试官…

高完整性系统工程(四): An Overview of Alloy

目录 1. 概述 2. 指定软件设计 3. 验证设计规范 4. 验证预期属性 1. 概述 在第一章中&#xff0c;我们将解释如何使用 Alloy 来探索一个非常简单的软件组件的设计&#xff0c;即大多数操作系统中存在的众所周知的垃圾箱 或回收站。目的是对如何使用 Alloy 指定和分析软件设…

MyBatis注解开发---实现自定义映射关系和关联查询

目录 一、使用注解实现自定义映射关系 1. 编写注解方法 2. 编写测试方法 3. 查看运行结果 二、使用注解实现一对一关联查询 1. 编写注解方法 2. 编写测试方法 3. 查看运行结果 三、使用注解实现一对多关联查询 1. 编写注解方法 2. 编写测试方法 3. 查看运行结果 四…

List接口中的ArrayList与LinkedList

ArrayList ArrayList的继承实现关系图 ArrayList 底层就是⼀个 Object[] 数组&#xff0c;当实例化ArrayList时没有指定数组容量大小&#xff0c;、第⼀次添加元素&#xff08;调⽤ add() ⽅法&#xff09;时会初始化为⼀个⻓度为 10 的数组&#xff08;即默认初始化容量为 1…

[Netty源码] ByteBufAllocator内存管理器相关问题 (十一)

文章目录1.ByteBufAllocator 内存管理器2.UnpooledByteBufAllocator2.1 heap内存的分配2.2 direct内存的分配3.PooledByteBufAllocator3.1 heap内存和direct内存的分配3.2 directArena分配direct内存的流程3.3 内存规格的介绍4.缓存的相关问题4.1 缓存的数据结果4.2 命中缓存的…

一维差分思想【算法推导、深刻思考】

797. 差分 - AcWing题库 差分本质上就是前缀和的逆运算 算法推导 其实在最开始自己去完成这个题目的时候&#xff0c;感觉好像是可以往前缀和方向靠的&#xff0c;但是一下子没有想到实现方法就无疾而终了。所以最后选择的算法就只是单纯的暴力&#xff08;虽然知道过不了&…

【操作系统复习】第5章 存储器管理

存储器的层次结构 存储层次 ➢ CPU寄存器 ➢ 主存&#xff1a;高速缓存、主存储器、磁盘缓存 ➢ 辅存&#xff1a;固定磁盘、可移动介质 层次越高&#xff0c;访问速度越快&#xff0c;价格也越高&#xff0c;存储容量也最小 寄存器和主存掉电后存储的信息不再存在&a…

2024软件工程考研之《软件工程导论》专业课复习

一、考察《软件工程导论》的学校 截止目前&#xff0c;考察《软件工程导论》的学校主要有&#xff1a; 大连理工大学887 北京航天航空大学991 北京交通大学901 河海大学846 海南大学835 新疆大学841 成都信息工程大学809 长安大学846 天津工业大学840 华东交通大学837 大连交通…

采购招投标系统-高效管控招采流程-降低采购成本

项目说明 随着公司的快速发展&#xff0c;企业人员和经营规模不断壮大&#xff0c;公司对内部招采管理的提升提出了更高的要求。在企业里建立一个公平、公开、公正的采购环境&#xff0c;最大限度控制采购成本至关重要。符合国家电子招投标法律法规及相关规范&#xff0c;以及…

软考证书找工作有用吗?软考找工作用处大吗

软考证书是衡量IT技术人才能力的一种重要评价标准。 一、软考高级证书对找工作的帮助 1. 竞争力增强 软考高级证书具有一定难度和较高的专业技能要求&#xff0c;拥有该证书的人的技术水平和专业能力会得到认可和尊重&#xff0c;从而增强求职者的竞争力。 2. 拓宽职业发展…

防火墙NAT实验,双机热备实验

目录 NAT防火墙基础实验 源地址转换 服务器映射 域内双向NAT 域间双向NAT 双机热备基础实验 主备备份 负载分担 NAT防火墙基础实验 实验拓扑&#xff1a; 1.进入防火墙图形化页面进行配置 接口列表的配置 源地址转换 企业内部网络访问外部网络&#xff0c;进行源地…

如何用nodejs构造一个网站爬虫

爬虫是个什么东西 英文spider&#xff0c;网络爬虫&#xff08;又称为网页蜘蛛&#xff0c;网络机器人&#xff0c;在FOAF社区中间&#xff0c;更经常的称为网页追逐者&#xff09;&#xff0c;是一种按照一定的规则&#xff0c;自动地抓取万维网信息的程序或者脚本。另外一些…

干货分享 | 采购没“云”和有云的区别有哪些?

多年前&#xff0c;提起“云”这个词&#xff0c;很多人还是“不知所云”。 但如今&#xff0c;大众对“云”的了解和认可程度也越来越高&#xff0c;尽情享受着“云”带来的便利。 通过“云”&#xff0c;可以随时随地畅听海量音乐、进行网购、访问云盘的照片和视频、在云端创…

【数据分析】——分析方法

上司要你帮忙看看公司最近的网站运营情况怎么样&#xff1f; 公司最近的网站运营情况&#xff1f;这个问题太宽泛了&#xff0c;你得要知道上司的明确需求 问题1:boss,你是想看看公司网站具体哪方面的问题&#xff1f; 回答&#xff1a;公司最近销售不太好&#xff0c;订单转…

Kubernetes 多集群网络方案系列 1 -- Submariner 介绍

Submariner 是一个完全开源的项目&#xff0c;可以帮助我们在不同的 Kubernetes 集群之间&#xff08;无论是在本地还是云端&#xff09;实现网络通信。Submariner 有以下功能&#xff1a; 跨集群的 L3 连接跨集群的服务发现Globalnet 支持 CIDR 重叠提供命令行工具 subctl 简…

MappedByteBuffer 详解(图解+秒懂+史上最全)

背景&#xff1a; 在尼恩视频版本里&#xff0c;从架构师视角&#xff0c;尼恩为大家彻底介绍 rocketmq 高可用、高并发中间件的原理与实操。 给大家底层的解读清楚 rocketmq 架构设计、源码设计、工业级高可用实操&#xff0c;含好多复杂度非常高、又非常核心的概念&#xff…

Python 小型项目大全 11~15

十一、标题党生成器 原文&#xff1a;http://inventwithpython.com/bigbookpython/project11.html 我们的网站需要欺骗人们去看广告&#xff01;但是想出有创意的原创内容太难了。幸运的是&#xff0c;有了标题党生成器&#xff0c;我们可以让一台计算机产生数百万个令人发指的…

在CentOS 7.5上用离线压缩包安装Python-3.9.10的过程记录

项目的需要&#xff0c;需要在CentOS 7.5上去部署一个Python 3.9.10的安装环境。 值得注意的是在CentOS 7.5系统中&#xff0c;默认安装了 Python 2.7.x。 Python 2.7.x 是许多系统工具和应用程序所依赖的版本&#xff0c;因此它被包括在 CentOS 7.5 发行版中。如果在 CentOS …

太全面了,数据治理8大核心模块建设参考

数据治理是一个去中心化、多元参与的系统工程。一个全面且明确的数据治理体系&#xff0c;可以帮助组织构建生态式、协同化治理路径&#xff0c;最大化地提升整体数据质量&#xff0c;实现数据战略&#xff0c;激活新型生产力。 本文以元数据、数据标准、主数据、数据交换、数…

Mybatis-Plus批量添加或修改数据的三种方式

SpringBoot批量添加或修改数据的三种方式 方式一.Mybatis-plus 提供的 saveOrUpdateBatch 提供的方法 是遍历每一个元素&#xff0c;判断主键是否存在&#xff0c;如果存在则做更新&#xff0c;不存在添加 方式二.分组数据再批量添加或修改 先获取表中所有的主键 &#xff0…