
python中字符串换行输出使用转义字符\n或使用三引号实现:
推荐手册:Python 基础入门教程
使用转义字符\n:
print("I'm Bob.\nWhat's your name?")输出结果:
I'm Bob. What's your name?
使用三引号:
python三引号允许一个字符串跨多行,字符串中可以包含换行符、制表符以及其他特殊字符。
立即学习“Python免费学习笔记(深入)”;
>>> hi = '''hi there''' >>> hi # repr() 'hi\nthere' >>> print hi # str() hi there
相关文章推荐:
1.用cmd写python怎么换行
2.python编写时怎么换行
相关视频推荐:
1.小甲鱼零基础入门学习Python视频教程
更多Python相关技术文章,请访问Python教程栏目进行学习!
以上就是python怎么把字符串换行输出的详细内容,更多请关注php中文网其它相关文章!
python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号