Python 情节:AttributeError:';int';对象没有属性';更换';
这里是关于AttributeError的:“int”对象没有属性“replace”。虽然部分代码来自plotly文档 有人能帮我解决这个精心设计的子地块错误吗:这个曾经用来运行,但现在它抛出了一个错误?我不明白Python 情节:AttributeError:';int';对象没有属性';更换';,python,pandas,plotly,Python,Pandas,Plotly,这里是关于AttributeError的:“int”对象没有属性“replace”。虽然部分代码来自plotly文档 有人能帮我解决这个精心设计的子地块错误吗:这个曾经用来运行,但现在它抛出了一个错误?我不明白 from plotly.subplots import make_subplots fig = make_subplots(rows=2) Tech = data2.Technologie.unique() import plotly.graph_objects as go from
from plotly.subplots import make_subplots
fig = make_subplots(rows=2)
Tech = data2.Technologie.unique()
import plotly.graph_objects as go
from plotly.validators.scatter.marker import SymbolValidator
raw_symbols = SymbolValidator().values
namestems = []
namevariants = []
symbols = []
for i in range(0,len(raw_symbols),2):
name = raw_symbols[i+1]
symbols.append(raw_symbols[i])
namestems.append(name.replace("-open", "").replace("-dot", ""))
namevariants.append(name[len(namestems[-1]):])
#fig = make_subplots(subplot_titles=("Demand"))
#range_y =[1200, 1800]
#Lignite1, Gas1, Hardcoal1, Demand1, PV1, Wind_Onshore1, Wind_Offshore1, Lit_Ion1, PSH1
---------------------------------------------------------------------------
AttributeError回溯(最近一次呼叫上次)
在里面
23名称=原始符号[i+1]
24符号。附加(原始符号[i])
--->25 namestems.append(name.replace(“-open”,”).replace(“-dot”,”))
26 namevariants.append(名称[len(名称项[-1]):]))
27
AttributeError:“int”对象没有属性“replace”
try name=str(原始符号[i+1])有哪些数据类型值?如果它只有字符串
,您可以使用replace()
,但即使它有一个int
,您也不能这样做!成功了。谢谢@NirElbaztry name=str(原始符号[i+1])原始符号[]有什么数据类型值?如果它只有字符串
,您可以使用replace()
,但即使它有一个int
,您也不能这样做!成功了。谢谢@尼勒巴兹
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-06419481b94d> in <module>
23 name = raw_symbols[i+1]
24 symbols.append(raw_symbols[i])
---> 25 namestems.append(name.replace("-open", "").replace("-dot", ""))
26 namevariants.append(name[len(namestems[-1]):])
27
AttributeError: 'int' object has no attribute 'replace'