代码如下:
def tell_your_name(name):
print(f"你的名字是{name.title}")
a=input("你的名字是:")
tell_your_name(str(a))
运行程序,效果如下:
不应该返回Tom,然后结束吗?为什么又运行了一遍而且没有返回Tom?谢谢
代码如下:
def tell_your_name(name):
print(f"你的名字是{name.title}")
a=input("你的名字是:")
tell_your_name(str(a))
运行程序,效果如下:
第一,他值运行了一遍,因为你input有个然后print打印了一个;第二,没有打印名字是因为你name后面加了title,直接应用name就行