python - 如何绘制用户界面
问题描述
注意:这是我的代码的样子,我不断收到粗体部分的错误,我希望能够绘制一条直线,其坐标从 1,1 开始,到 (1+lineLength), 1 结束,这样我就有了一条水平线。我对python不太熟悉,所以我非常感谢您的意见。
lineLengthQuestion = input("What size would you like your line? (Numbers Only)")
lineLengthQuestion = int(lineLengthQuestion)
lineLength = [1 + lineLengthQuestion]
print (f'You entered {lineLengthQuestion}')
x = [1,1]
y = [lineLength, 1]
plt.plot(x, y, color = "black", linewidth = 3)
解决方案
您创建了一个单元素列表,其中包含一个比 大 1 的数字lineLengthQuestion
。我认为你想要一个标量值,所以你不需要括号。
lineLength = 1 + lineLengthQuestion
推荐阅读
- javascript - 如何修改此代码以在循环内创建循环?
- javascript - 使用 else-if 和 JavaScript 有什么区别
- python - 从列表python中删除循环/重复
- webpack-5 - Webpack 5 共享块文件名
- shopify - 如何在shopify后台添加第三方加速结账方式
- excel - 将查找类型字段从 excel 导入 Power Apps Dataverse 时出现问题
- javascript - 如何将 JS 变量分配给 JSON 路由
- ios - 在 MacOS Big Sur 上找不到“openssl/conf.h”文件错误
- python - 如何使用python根据另一个excel表过滤一个excel中的行?
- gradle - 我希望有可能拥有一个带有 gradle 约定的 buildsrc 并构建一个多项目