python 統計使用技巧

python 統計使用技巧python


# 一、不輸入回車獲取值ios

注:須要tty模塊配合。ui

fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(1) # 值個數
termios.tcsetattr(fd,termios.TCSADRAIN,old_settings)

# 二、進度條spa

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()

# 三、uid 反查code

getent passwd 48
user = os.popen("getent passwd %s | awk -F':' '{print $1}'"%(self.user))
process_user = user.read()
相關文章
相關標籤/搜索