交换两个变量的值

代码:

def func(x,y):
    x,y = y,x
    print("新X的值为{},新Y的值为{}".format(x,y))
x = int(input("请输入X的值:"))
y = int(input("请输入Y的值:"))
func(x,y)

结果:

请输入X的值:2
请输入Y的值:3
新X的值为3,新Y的值为2

 

 

posted @ 2019-12-03 18:00  代码怪lh  阅读(368)  评论(0)    收藏  举报