How to use newline character in python?

little bottle
Release: 2019-11-23 14:24:27
Original
34906 people have browsed it

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

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

推荐手册Python 基础入门教程

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

How to use newline character in python?

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

print "ab\nc"
Copy after login

ab

c

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

print "ab\r\nc"
Copy after login

ab

c

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

print "\\n"
Copy after login

\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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Articles by Author
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!