【发布时间】:2013-03-28 22:01:13
【问题描述】:
我的代码的 sn-p:
def determinewelltype(currentuwi,welltype):
if current uwi in vertuwis:
welltype = "Vertical"
currentuwi = "1aa010109306w400"
welltype = "UNKNOWN"
determinewelltype(currentuwi,welltype)
print currentuwi,welltype
在我的代码的另一部分,我构建了一个名为 vertuwis 的列表,它由许多字符串组成。
这个 sn-p 正在尝试确定 currentuwi 是否在 vertuwis 列表中。如果是,井型应该是垂直的。
我知道给定的 currentuwi 在我的列表中,但是当我在最后一行代码中打印井类型时,井类型是 UNKNOWN,这意味着我的代码不起作用。
我哪里出错了?
【问题讨论】:
-
参数在 python 中是按值传递的,但你假设它们是由 ref 传递的。查看下面的问题,它详细解释了这一点stackoverflow.com/questions/986006/…