【问题标题】:Assigning value to a parameter in Python在 Python 中为参数赋值
【发布时间】:2013-04-17 20:53:41
【问题描述】:
>>> import sys
>>> def hello(name):
    name='Hello, ',name,' !'
    print name

这是我的代码。如何为参数“name”赋值?

【问题讨论】:

  • 你需要阅读Python教程def hello(name): print 'Hello', name

标签: python parameters arguments


【解决方案1】:

你是说

input = "whatever"
hello(input)

【讨论】:

  • 哈哈,是的。我在输入字符串时没有放逗号。
  • 我在写 - hello(World) 而不是 hello('World')
  • 要连接单词,请使用+ 而不是,。
  • 我在使用 ',' 时得到了一个元组
  • @user2278992 阅读教程并不是最糟糕的主意。
猜你喜欢
  • 1970-01-01
  • 2021-11-08
  • 2012-03-18
  • 1970-01-01
  • 1970-01-01
  • 2012-08-18
  • 2019-05-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多