首页 > 解决方案 > 在单元测试中生成 EOF 错误,但如果我自己运行它则不会

问题描述

即使我的代码运行良好,我也会收到 EOF 错误

我曾尝试简化我的代码并搜索语法错误,但它运行良好。

sentence = input('Enter a sentence or phrase: \n')

print('You entered: ', end='')
print(sentence)

def get_num_of_characters(inputStr):
    print()

    return len(inputStr)

def output_without_whitespace(strpo):

    caki = strpo.replace(' ','')
    return caki


print('Number of characters:',get_num_of_characters(sentence))
print('String with no whitespace:',output_without_whitespace(sentence))

在运行单元测试之前,没有空格的字符数和字符串的输出工作正常,然后我收到 EOF 错误。

标签: python-3.xeof

解决方案


推荐阅读