Java 条件语句 - if...else

Java 中的条件语句允许程序根据条件的不同执行不同的代码块。 一个 if 语句包含一个布尔表达式和一条或多条语句。 语法 if 语句的语法如下: if(布尔表达式) { //如果布尔表达式为true将执行的语句 } 如果布尔表达式的值为 true,则执行 if 语句中的代码块,否则执行 else 语句块后面的代码。 if…else语句 if 语句后面可以跟 else 语句,当 if 语句的布尔表达式值为 false 时,else 语句块会被执行。 语法 if…else 的用法如下: ...

November 6, 2023 · Leon

Java 利用三元运算符实现 '多元运算'

一元运算符:只需要一个数据就可以进行操作的运算符。例如:取反!、自增++、自减– 二元运算符:需要两个数据才可以进行操作的运算符。例如:加法+、赋值= 三元运算符:需要三个数据才可以进行操作的运算符, 格式: 数据类型 变量名称 = 条件判断 ? 表达式A : 表达式B; String a = b > 1 ? "大" : "小"; 比如四元运算, String a == 1 ? "壹":(a == 2 ? "贰" : "叁"); 比如五元运算, public static void main(String[] args) { Integer age= 35; System.out.println(age > 65 ? "老年人" : (age >= 35 ? "中年人" : (age > 14 ? "青年人" : "儿童"))); }

October 13, 2023 · Leon

What is a DPU?

数据处理单元(Data processing unit,DPU)是一种可编程电子电路,它具有数据处理以及硬件加速功能,数据处理单元主要用于数据中心内的数据计算处理。一个DPU通常含有一个中央处理器 、 网卡和可编程数据硬件加速引擎,因此DPU可以像中央处理器那样处理数据的同时还可以处理网络封包。 CPU v GPU v DPU: What Makes a DPU Different? A DPU is a new class of programmable processor that combines three key elements. A DPU is a system on a chip, or SoC, that combines: An industry-standard, high-performance, software-programmable, multi-core CPU, typically based on the widely used Arm architecture, tightly coupled to the other SoC components. A high-performance network interface capable of parsing, processing and efficiently transferring data at line rate, or the speed of the rest of the network, to GPUs and CPUs. A rich set of flexible and programmable acceleration engines that offload and improve applications performance for AI and machine learning, zero-trust security, telecommunications and storage, among others. ...

November 14, 2022 · Leon

Pyinstaller 打包Python 成exe

安装: pip install pyinstaller 如果安装慢,可引用清华源: # 清华源 pip install pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple/ cmd 切换到 python 文件的目录,执行命令: pyinstaller -F -w -i python.ico watermark.py 在dist 文件夹下,可以找到打包好的exe 文件 详细参数 在上面的打包命令中,用到了好几个参数:-F,-W,-i,这些参数的含义如下面的表格: 参数 用法 -F 生成结果是一个 exe 文件,所有的第三方依赖、资源和代码均被打包进该 exe 内 -D 生成结果是一个目录,各种第三方依赖、资源和 exe 同时存储在该目录(默认) -a 不包含unicode支持 -d 执行生成的 exe 时,会输出一些log,有助于查错 -w 不显示命令行窗口 -c 显示命令行窗口(默认) -p 指定额外的 import 路径,类似于使用 python path -i 指定图标 -v 显示版本号 -n 生成的 .exe 的文件名 pyinstaller -F -w -i python.ico watermark.py 就表示 -F,打包只生成一个 exe 文件,-w,在运行程序的时候不打打开命令行的窗口,-i 就是打包带有自己设置的 ico 图标。 ...

October 15, 2022 · Leon

Windows下 PyAutoGUI

PyAutoGUI 通过Python scripts自动控制鼠标和键盘的一系列操作来控制其它程序,已达到自动化(测试)目的。 安装方式, Windows上,可以使用py.exe 运行最新版本的Python: py -m pip install pyautogui 如果安装了多个版本的Python,需要指明版本号,如Python 3.8: py -3.8 -m pip install pyautogui 按键精灵实践, import pyautogui,time print(pyautogui.position()) while True: pyautogui.moveTo(960, 600, duration=1) # 移动到 (960,600) pyautogui.mouseUp() # 鼠标释放 pyautogui.click() # 鼠标当前位置点击一下 pyautogui.mouseUp() # 鼠标释放 time.sleep(238) pyautogui.mouseUp() # 鼠标释放 常用功能 ...

October 15, 2022 · Leon

Bludit的nginx配置

伪静态,nginx里添加如下配置即可,可避免安装后/admin 出现404的状况 location / { try_files $uri $uri/ /index.php?$args; } location ^~ /bl-content/tmp/ { deny all; } location ^~ /bl-content/pages/ { deny all; } location ^~ /bl-content/databases/ { deny all; }

January 3, 2022 · Leon