python 统计使用技巧


# 1、不输入回车获取值

注:需要tty模块配合。

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)

# 2、进度条

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

 

相关文章:

  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
  • 2021-11-09
猜你喜欢
  • 2022-02-11
  • 2022-01-11
  • 2021-12-08
  • 2022-12-23
  • 2021-12-19
  • 2021-04-23
  • 2021-09-01
相关资源
相似解决方案