小编Tha*_*tis的帖子

删除并替换在Python中打印到终端的最后一个字符

我有这段代码可以读取通过多路复用器和ADC连接到GPIO的16个模拟模拟传感器,并将所有内容相应地转换为一个字符,然后将每个字符并排写入终端,如何删除和替换最后一个打印的字符?现在,它仅覆盖最后打印的字符,并在其旁边立即打印新字符。这个项目的目的是创建一个老式的短信模拟器。

这是我的代码:

#!/usr/bin/python
import time
import RPi.GPIO as GPIO
import spidev # import the SPI driver
from time import sleep
from array import *
DEBUG = False
vref = 3.3 * 1000 # V-Ref in mV (Vref = VDD for the MCP3002)
resolution = 2**10 # for 10 bits of resolution
calibration = 38 # in mV, to make up for the precision of the components
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
start_time=time.time()
elapsed_time=time.time()
keypressed=0
i=0
keyreleased …
Run Code Online (Sandbox Code Playgroud)

python terminal character python-3.x raspberry-pi2

2
推荐指数
1
解决办法
944
查看次数

如何在不使用while循环的情况下在python3中重复一个函数?

我在python中有一个函数需要不断运行并检查一些变量.目前我有一个while循环,一切都顺利运行,直到我想使用pyqt小部件,最终导致灾难.

我已经在stackoverflow中的其他线程上找到了twisted.internet模块,但我不能让它在python3上运行.

是否有另一个模块允许我重复某个函数在python3中每0.01秒运行一次而不会闲置我的代码?

python repeat python-3.x

-1
推荐指数
1
解决办法
640
查看次数

标签 统计

python ×2

python-3.x ×2

character ×1

raspberry-pi2 ×1

repeat ×1

terminal ×1