如何在Python中获取用户名?

时间:2010-12-01 14:34:55

标签: python

  

可能重复:
  Is there a portable way to get the current username in Python?

如何获取执行给定脚本的帐户的用户名?

1 个答案:

答案 0 :(得分:75)

import getpass
print getpass.getuser()