难道只能在Pycharm专业版中创建类图吗? 我有 Pycharm Community Edition 2019.2 并且已经安装了
PlantUML plugin
和 Graphviz
,还根据需要设置了环境变量,但仍然无法创建类图。
根据网上的搜索,我认为你的问题的具体答案是肯定的,你只能使用专业版集成的UML插件。要在社区版中执行此操作,正如 Dinko 所说,您必须使用第 3 方插件 PlantUML。
生成 UML。也许您已禁用它们。转到
File -> Settings -> Plugins
并搜索 UML。应该有 Python UML
图表和 UML
,下面应该写有 bundled 关键字。
您可以右键单击班级并选择
Diagrams
来生成它。
例如这堂课:
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
表示为:
对于
PlantUML
插件,除了插件本身之外,您无需安装任何东西。安装时,您可以创建新的PlantUML
文件并选择要生成的默认图表。
您可以使用 Pycharm 社区版 pylint 中的 Pyreverse。
pip install pylint
pyreverse -o puml <src path>
def search_by_description(): description = input("请输入要搜索的商品描述:")
inventory = []
with open("inventory.txt", "r") as file:
for line in file:
data = line.strip().split("\t")
inventory.append(data)
found = False
for item in inventory:
if description.lower() in item[1].lower():
found = True
print("Item details:")
print(f"Item Code: {item[0]}")
print(f"Description: {item[1]}")
print(f"Category: {item[2]}")
print(f"Unit: {item[3]}")
print(f"Price: {item[4]}")
print(f"Quantity: {item[5]}")
print(f"Minimum Threshold: {item[6]}")
print()
if not found:
print("No items found with the given description.")