我有两个问题:
如果str()或list()对象可能最终为空,例如:asr=''或alist=[],那么您可能希望使用alist[-1:]而不是alist[-1]来表示对象“相同性”
some_list = [1, 2, 3]
some_list[-1] = 5 # Set the last element
some_list[-2] = 3 # Set the second to last element
some_list
a_list = ['zero', 'one', 'two', 'three']
a_list[-1]
'three'
听着,你基本上已经做对了,但为了记录在案,这里是工作代码:
注意,因为我没有两个文件,所以我没有导入
EN
,因此删除了函数调用前面的EN.
。我还将epsilon
参数添加到Duct
类中,该类在您的版本中丢失,并将其传递给simplified_friction_method
函数。有很多方法可以改进代码,但现在我认为更重要的是它能工作并且你能理解它。你显然不知道类是如何工作的,所以我建议你look into that最小工作负载示例如上所述
相关问题 更多 >
编程相关推荐