我正在尝试编写一个 Python 程序,该程序基本上将原始 Python 源文件作为输入,并将所有变量名称更改为 V,将所有方法或函数名称更改为 F,并保留其他所有内容不变。所以我正在努力实现这一目标:
输入:
def gcd(x, y):
"""Sample docstring."""
if x == y:
return x
if x > y:
if y == 0: return x
return gcd(x-y, y)
if y > x:
if x == 0: return y
# Sample comment.
return gcd(x, y-x)
Run Code Online (Sandbox Code Playgroud)
输出:
def F(V, V):
"""Sample docstring."""
if V == V:
return V
if V > V:
if V == 0: return V
return F(V-V, V)
if V > V:
if V == …
Run Code Online (Sandbox Code Playgroud) 我有一个名为Orders Like Table的表:
OrderItemID CustomerIDNumber OrderProcessed
1 9212060068089 False
2 6412180017080 False
3 9212060068089 False
4 5508245127003 False
5 9212060068089 False
Run Code Online (Sandbox Code Playgroud)
我想做的事情,我似乎真的很难得到正确的,是选择订单处理错误的所有唯一客户ID号.
现在这很简单,通过使用DISTINCT,但我正在努力的TRICKY PART,是我希望客户ID号仍然按订单商品ID维护订单.所以示例输出应该是:
CustomerIDNumber OrderProcessed
9212060068089 False
6412180017080 False
5508245127003 False
Run Code Online (Sandbox Code Playgroud)
请注意:处理顺序中的所有值都在这里错误,显而易见地在我的表中,对于订单处理将有一些真正的价值.
这是我目前得到的错误输出:
CustomerIDNumber OrderProcessed
5508245127003 False
6412180017080 False
9212060068089 False
Run Code Online (Sandbox Code Playgroud)
可以看出,它是按升序对客户ID号进行排序,这不是我想要的.