python 统计使用技巧
生活随笔
收集整理的這篇文章主要介紹了
python 统计使用技巧
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、不輸入回車(chē)獲取值
注:需要tty模塊配合。
fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) tty.setraw(sys.stdin.fileno()) ch = sys.stdin.read(1) # 值個(gè)數(shù) termios.tcsetattr(fd,termios.TCSADRAIN,old_settings)2、進(jìn)度條
''' 遇到問(wèn)題沒(méi)人解答?小編創(chuàng)建了一個(gè)Python學(xué)習(xí)交流QQ群:778463939 尋找有志同道合的小伙伴,互幫互助,群里還有不錯(cuò)的視頻學(xué)習(xí)教程和PDF電子書(shū)! ''' int = 0 percent = ("%s%%"%int) sys.stdout.write("\r[%-100s]%s"%("|" * int,percent)) term.write("\r[%-10s]%s"%("|" * int(intt/10),percent)) sys.stdout.flush()3、uid 反查
getent passwd 48 user = os.popen("getent passwd %s | awk -F':' '{print $1}'"%(self.user)) process_user = user.read()總結(jié)
以上是生活随笔為你收集整理的python 统计使用技巧的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Python函数传参方式超级大汇总
- 下一篇: Python执行精确的浮点数运算