1. sys.argv
# cat test.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
print sys.argv
sys.exit()
# python test.py 1 2 3 4 5
结果:['test.py', '1', '2', '3', '4', '5']
2.os.path.basename
# cat opb.py
#! /bin/env python
# -*- coding: utf-8 -*-
import os
path1="/etc/rc.d/init.d/network"
os.path.basename(path1)
# python opb.py
结果:network
转载请注明原文地址: https://ju.6miu.com/read-1234.html