代码中的错误是
psspy.three_wnd_winding_data_3(from_,to,last_bus,r"""1""",1,[_i,_i,_i,_i,_i],[_f,_f,_f,_f,_f,_f,_f,_f, max_value, min_value,_f,_f,_f])
TypeError: an integer is required
我以为我已经把字符串转换成整数了。我很困惑。因为其他变量year_link
、tla_2
、min_value
、max_value
不需要我使用isinstance
和isdigit
。变量被转移到psspy
函数数组中。错误是,它正在读取last_bus
的字符串值。是否有人知道如何解决这个问题,并能向我解释为什么我必须转换excel工作表最后一列的字符串。Excel Sheet
for row in data:
year_link, from_,to,digit,name2,tla_2,min_value,max_value,last_bus = row[7:16]
if isinstance(last_bus, str) and year_link==year and tla_2==location and last_bus.isdigit() is True:
min_value=float(min_value)
max_value=float(max_value)
last_bus=int(last_bus)
output = 'From Bus #: {}\tTo Bus #: {}\tLast Bus #: {}\t Area Station: {}\t VMIN: {} pu\tVMAX: {} pu\t'
print(output.format(from_, to,last_bus,name2, min_value, max_value))
print("\n")
psspy.three_wnd_winding_data_3(from_,to, last_bus,r"""1""",1,[_i,_i,_i,_i,_i],[_f,_f,_f,_f,_f,_f,_f,_f, max_value, min_value,_f,_f,_f])
else:
exit
Excel没有整数数据类型;因此
from_
和to
实际上可能是python中的float
对象。你知道吗以记录宏功能提供的格式向
psspy
函数发送参数容易出错。使用关键字参数的以下方法更好:阅读docstring在这里是至关重要的。您可以阅读API文档。你知道吗
相关问题 更多 >
编程相关推荐