如何为多个对象设置相同的参数/选项?

发布于 2025-02-02 12:41:25 字数 541 浏览 2 评论 0原文

我开始学习如何使用Manin并发现以下问题。

假设我希望我的视频中使用font =“ Calibri”font_size = 72

然后,我必须编写以下代码:

Text("Text 1",font="Calibri",font_size=72)

之后,如果我想再次使用相同的文本样式,我必须再次编写函数的参数/选项text()

Text("Text 2",font="Calibri",font_size=72)

所以我的问题是,是否可以使用text()的参数/选项定义变量,以便我每次都要复制和粘贴它们?

像这样的事情:

options={font="Calibri",font_size=72}

Text("Text 1",options)

Text("Text 2",options)

这简直就是事情。

I started to learn how to use manin and found the following problem.

Suppose that I want the text in my video with font="Calibri" and font_size=72.

Then I have to write the following code:

Text("Text 1",font="Calibri",font_size=72)

After that, if I want to use the same style of text again, I have to write again the parameters/options of the function Text():

Text("Text 2",font="Calibri",font_size=72)

So my question is, is it possible to define a variable with the parameters/options for Text() so I won't have to copy and paste them every time?

Something like this:

options={font="Calibri",font_size=72}

Text("Text 1",options)

Text("Text 2",options)

that would simply things.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绿光 2025-02-09 12:41:25

我弄清楚了!我只需要def一个函数:

def font_1(text):
    new_text=Text(text,font="Calibri",font_size=72)
    return new_text

然后witte “ text 1” and “ text 2”与相同的形式我只使用代码

font_1("Text 1")
font_1("Text 2")

I figured it out! I just have to def a function:

def font_1(text):
    new_text=Text(text,font="Calibri",font_size=72)
    return new_text

Then to writte "Text 1" and "Text 2" with the same formate I just use the code

font_1("Text 1")
font_1("Text 2")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文