python-3.x - 在单元测试中生成 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 错误。
解决方案
推荐阅读
- unity3d - 如何将统一工作应用程序部署到 HoloLens 1?
- ms-access - 有没有办法在不重新启动数据库的情况下应用 MS Access 中的设置?
- r - 基于两个条件循环数据帧的子集
- javascript - 如何使用 cypress 命令编写可重用的 javascript 函数
- mysql - java.sql.SQLInvalidAuthorizationSpecException:用户'root'@'10.24.1.77'的访问被拒绝(使用密码:是)
- javascript - 在 child_process 中并行运行多次相同的命令
- security - Mule 4 安全属性占位符不起作用
- java - %Like% 在spring JpaRepository中查询N个字段
- .net - 在 Delphi 7 中调用 C++ DLL 函数
- java - Keycloak 无法获取访问令牌