【问题标题】:I am getting an error while using the centre function in python在 python 中使用 center 函数时出现错误
【发布时间】:2022-12-11 02:50:18
【问题描述】:

每当我运行这样写的代码时:

a = "Welcome to the console" print(a.centre(50))

我收到错误消息“属性错误:str 对象没有属性中心”

如果出现愚蠢的错误,我会尽我所能,请原谅我,我是一名 12 岁的新开发人员。

【问题讨论】:

  • 打印(a.centre(50))在底部没有在顶部堆栈溢出是自动完成的
  • 试试a.center(50)!这里的区别是center而不是centre

标签: python string


【解决方案1】:

这可能是你想要的:

a = "Welcome to the console"

print(a.center(50))

你可能打错了字!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-20
    • 1970-01-01
    • 2019-03-02
    • 1970-01-01
    • 1970-01-01
    • 2019-05-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多