简体   繁体   English

这里的 len() 有什么意义?

[英]what the point of the len() here?

I'm learning the Pyautogui module, i have came to a script where it print the position of the mouse for you.我正在学习 Pyautogui 模块,我来到了一个脚本,它为你打印鼠标的 position。 and delete previous output, so it look like the output is updating.并删除之前的 output,所以看起来 output 正在更新。

but i understand everything here but i dont understand what does *len(strPosition) exactly is there for?但我了解这里的一切,但我不明白 *len(strPosition) 到底是做什么用的?

#!/usr/bin/env python3
import pyautogui


try : 
    while True:
        x,y = pyautogui.position()
        strPosition = ' X : '+str(x).rjust(4)+' Y : '+str(y).rjust(4)
        print(strPosition,end='')
        print('\b'*len(strPosition) ,end='',flush=True)
except KeyboardInterrupt :

    print('\nDone.')

Constructs like:构造如下:

print('a string' * NUM)

mean: print 'a string' NUM number of times.意思是:打印 'a string' NUM 次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM