Skip to main content
 首页 » 编程设计

python之将结果写入 Python 中的参数

2025年05月04日11mfrbuaa

如何将结果写入传递的参数(arguments)?

### permutation function 
 
def xchg(a, b): 
    """ xchg function that does a permution for two integers 
    """ 
    a=a+b 
    b=a-b 
    a=a-b 
 
a=int(input("Enter a number: ")) 
b=int(input("Enter another number: ")) 
xchg(a,b) 
print("a= ", a) 
print("b= ", b) 

请您参考如下方法:

如果您正在学习 Python,您应该学习如何编写 Python,而不是学习如何用 Python 编写 C 或 Java。

在 Python 中,这样做没有意义。好多了:

b, a = a, b