在 python 中回车 \r 返回一个音符 [英] In python carriage return \r returns a musical note

查看:45
本文介绍了在 python 中回车 \r 返回一个音符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

print "-------------------\r"

产生一个音符而不是回车.为什么?

produces a musical note instead doing the carriage return. Why?

提前感谢您的回复.

我在这段代码中使用它是为了通过打印"更改动态数据而不是重新打印所有数据:

I was using it in this code in order to change dinamically data by 'print' instead to re-print it all:

import math
import time

    while True:
        reading = read_world_2c(0x43) #it's a function for reading data from a sensor
        print "data:     \r", reading
        time.sleep(0.5) 

推荐答案

那个音符是换行符的符号.如果您有 MS Word 或 Notepad++ 或类似软件,请打开或键入一些文本,然后找到显示非打印字符"的菜单命令.你会在每一行的末尾看到那些音符".

That musical note is the symbol for line breaks. If you have MS Word or Notepad++ or similar, open or type some text and then find the menu command for "show nonprinting characters ". You will see those "musical notes" at the end of each line.

这篇关于在 python 中回车 \r 返回一个音符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆