简体   繁体   English

TypeError: unsupported operand type(s) for /: 'list' and 'int' 解决方案是数组

[英]TypeError: unsupported operand type(s) for /: 'list' and 'int' solution is an array

import numpy as np
from sympy import symbols, solve
x = symbols('x')
expr1 = -2*x + x**2 + 1
a = solve(expr1)
print(a)
p = a/2
expr2 = -4*x + x**2 + a
z = solve(expr2)
print(z)
 5 a = solve(expr1)
      6 print(a)
----> 7 p = a/2
      8 expr2 = -4*x + x**2 + a
      9 z = solve(expr2)

TypeError: unsupported operand type(s) for /: 'list' and 'int'

I solved an equation, the answer is an array.我解了一个方程,答案是一个数组。 I am trying to use the answer for a new equation.我正在尝试使用新方程式的答案。 I wrote a sample code to explain my problem!我写了一个示例代码来解释我的问题!

I see you want to "use the answer for a new equation".我看到您想“使用新方程式的答案”。

The previous equation solution is a , a list with 1 element [1]前面的方程解是a ,一个包含 1 个元素的列表[1]

then you can use a[0] in your next equation那么你可以在你的下一个等式中使用 a[0]

expr2 = -4*x + x**2 + a[0]
z = solve(expr2)
print(z)

and p=a/2 is totally useless, you didn't use p after that.并且p=a/2完全没用,在那之后你没有使用p

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:/:'list'和'int'不支持的操作数类型 - TypeError: unsupported operand type(s) for /: 'list' and 'int' 类型错误:不支持 // 的操作数类型:'list' 和 'int' - TypeError: unsupported operand type(s) for //: 'list' and 'int' TypeError:不支持的操作数类型 - :'list'和'int' - TypeError: unsupported operand type(s) for -: 'list' and 'int' TypeError:不支持的操作数类型 - :'int'和'list' - TypeError: unsupported operand type(s) for -: 'int' and 'list' typeerror不支持%:'list'和'int'的操作数类型 - typeerror unsupported operand type(s) for %: 'list' and 'int' TypeError:+不支持的操作数类型:“ int”和“ list” - TypeError: unsupported operand type(s) for +: 'int' and 'list' 类型错误:+= 不支持的操作数类型:'int' 和 'list' - TypeError: unsupported operand type(s) for +=: 'int' and 'list' TypeError:/:28次迭代后,/:“ list”和“ int”不受支持的操作数类型 - TypeError: unsupported operand type(s) for /: 'list' and 'int' after 28 iterations 类型错误:% 不支持的操作数类型:'list' 和 'int' | 很有趣的案例? - TypeError: unsupported operand type(s) for %: 'list' and 'int' | very interesting case? Python TypeError:+不支持的操作数类型:'int'和'list' - Python TypeError:unsupported operand type(s) for +: 'int' and 'list'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM