如果我有两种方法:
string
更改为tuple
并将其返回。tuple
返回的内容。最后我该怎么做?
输入类似于"12345 firstName lastName otherInfo"
。
def information(sentence):
splitUp = sentence.split(' ')
return sentence
def printAsString():
"".join(sentence)
print(sentence)
答案 0 :(得分:2)
这是一种方法。但你的目标是什么?这段代码有点无意义......
def information(sentence):
'''Splits the sentence on space and returns it as tuple'''
split_up = tuple(sentence.split(' '))
return split_up
def print_as_string():
'''Prints tuple as string'''
sentence = "welcome to SO dear friend"
print(" ".join(information(sentence)))
if __name__ == "__main__":
print_as_string()
答案 1 :(得分:1)
这将是
print ''.join(employeeInfo)
但我的问题是employeeInfo到底在哪里形成?