如何使用 UliEngineering 在 Python 中根据功率和电压计算电流

你可以使用 UliEngineering Python 库,根据功率和电压轻松计算电流:

current_by_power.py
from UliEngineering.Electronics.Power import *
from UliEngineering.EngineerIO import *

# 计算 5V 下 5W 对应的电流
current = current_by_power("5W", "5V")
print(f"Current for 5W at 5V: {format_value(current, 'A')}")

# 计算 12V 下 6W 对应的电流
current = current_by_power("6W", "12V")
print(f"Current for 6W at 12V: {format_value(current, 'A')}")

示例输出

current_by_power_output.txt
Current for 5W at 5V: 1.00 A
Current for 6W at 12V: 500 mA

电流使用以下公式计算:$I = \frac{P}{V}$

相关文章


Check out similar posts by category: Electronics, Python