python - 将结果写入 Python 中的参数?

标签 python

如何将结果写入传递的参数(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

关于python - 将结果写入 Python 中的参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14540226/

相关文章:

python - 制作影响输入参数索引中的元素的函数输出列表

python - 在包含 M*N 个混洗元素的列表中找到 N 个元素的 M 个算术序列

python - 解码中文停用词文件并附加到列表

python - 什么是 tf.losses.absolute_difference 的替代品

python - 为 Linux 命令编写 Python 脚本

python - 尝试从 python 字典中获取项目时出现 "TypeError: string indices must be integers, not str"

python - 导入错误:没有名为 py31compat 的模块

python - 在 python 和嵌套列表中的 for 循环中追加

Python:查看注册表以查找程序的安装位置

python - 使用 Python 接受 MS Word 文档中的所有更改