【发布时间】:2017-12-14 15:26:18
【问题描述】:
通过打印出 raw_input() 在末尾出现一个“none”。
我在上面定义了一个打印问题时看起来不错的函数。
这是我的代码:
def delay_print_input(string):
for c in string:
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(0.15)
ans=raw_input(delay_print_input("What do you want?\n>> "))
输出如下:
What do you want?
>> None
我的问题是,我怎样才能删除这个无?
【问题讨论】:
-
因为你的函数返回
None -
你应该在你定义的函数的末尾使用return语句
-
这能回答你的问题吗? Random None when printing from raw_input
标签: python-2.x