sys模块
import os
import sys
print(sys.argv)##命令模式下获取路径
print(sys.argv[0])##获取脚本名
print(sys.version)##获取python版本,类型为字符串
if sys.version[0] == ‘2’:
print(‘running in python2’)
else:
print(‘running in python3’)
print(sys.path)##初始化python的环境变量
print(sys.platfrom) ##打印所属平台
if sys.platform == ‘linux’:
os.system(‘ifconfig’)
else:
os.system(‘ipconfig’)
第三方模块
##生成二维码(直接跳转至百度)
对于该类信息,一定要注意自身信息安全
import qrcode
img = qrcode.make(‘http://www.baidu.com’)
img .save(‘hello.png’)
##生成二维码,扫描后会一直收到信息,需要itchat模块支持
import time
import random
import itchat
itchat.auto_login()
while True:
itchat.send(‘hello westos’,toUserName=‘filehelper’)
time.sleep(random.randint(1,3))
itchat
import os
import itchat
@itchat.msg_registeer(itchat.content.Text,isFriendChat=True)
def text_reply(msg):
if msg[‘ToUserName’] == ‘filehelper’:
command = msg[‘content’]
if os.system(command) == 0:
res = os.popen(command).
itchat.auto_login()
itchat.run()