python -c 参数 -m 参数 和 bash --rcfile 参数的解释
python3 -c command [arg]
后面接要执行的python语句
举例
$ python3 -c 'print("Hello")'
Hello
python3 -m module [arg]
后面接一个模块及参数
$ python3 -m usescanner.py data.txt
Hello file world!
Bye filel world.
$ cat usescanner.py
#!/usr/local/bin/python
from sys import argv
from scanfile import scanner
filename = './data.txt'
filename = argv[1]
scanner(filename)
$ cat scanfile.py
def scanner(name):
file = open(name,'r')
while True:
line = file.readline()
#if not
if not line: break
#function(line)
print(line)
file.close()
$ cat data.txt
Hello file world!
Bye filel world.
bash命令的--rcfile参数,指定另一个脚本代替.bashrc。
cat ./scripts/dshell
#!/bin/bash
DATA_DIR=`python3 -c "import dshell.util; print (dshell.util.get_data_path());"`
/bin/bash --rcfile "$DATA_DIR/dshellrc"
更多推荐



所有评论(0)