Home >Backend Development >Python Tutorial >How to use newline character in python?

How to use newline character in python?

little bottle
little bottleOriginal
2019-05-21 09:38:2835059browse

欸,这个python换行符怎么用?

虽说Python语法简单,但是,有时还是会忘记到底应该怎么用换行符。

推荐手册Python 基础入门教程

下面和小编一起学习一下吧。

How to use newline character in python?

当单纯是打印输出时,想获得换行效果:

print  "ab\nc"

ab

c

在文件操作时想读取到换行效果,必须写成:

print "ab\r\nc"

ab

c

想真正获得/n普通含义,则需要

print "\\n"

\n

相关文章推荐:
1.python移除字符串中的换行符
2.对Python字符串中的换行符和制表符介绍
相关视频推荐:
1.小甲鱼零基础入门学习Python视频教程

The above is the detailed content of How to use newline character in python?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn