# 获取域的名称import osdomain = os.environ['userdomain']print(domain)#获取用户名import getpassimport osprint(os.getlogin())print(getpass.getuser())
import json, requests, socket, uuidfrom datetime import datetime#获取年月日时分秒now_time = datetime.now()now_time = now_time.strftime("%Y%m%d%H%M%S")#获取mac地址address = hex(uuid.getnode())[2:]print('-'.join(address[i:i+2] for i in range(0, len(address), 2)))print(now_time)#获取计算机名print(socket.gethostname())
>>> import socket>>> hostname = socket.gethostname()>>> hostname'DESKTOP-I734J3O'>>> socket.gethostbyname(hostname)'192.168.0.103'
参考
/question/p-dpdhfyha-np.html
/p/d7b51e897d56