Python 中的 string.whitespace

pythonserver side programmingprogramming更新于 2025/8/1 22:36:17

在本教程中,我们将学习 string.whitespace。

字符串 whitespace 在 Python3 的 string 模块中预定义。它包含 space、tab、 linefeed、return、formfeed 和 vertical tab。

示例

# 导入字符串模块
import string
# 打印字符串
print("Hello")
# 打印空格
print(string.whitespace)
# 打印字符串
print('tutorialspoint')

输出

如果您运行上述代码,那么您将获得以下结果。

Hello

tutorialspoint

结论

如果您对本教程有任何疑问,请在评论部分中提及。


相关文章


有用资源