问题shell脚本如何遍历文件夹下所有文件?
方法:
dir="./sql_to_hdfs_init"
for file in `ls $dir/*`
do
echo $file # 输出 ./sql_to_hdfs_init/a.sh
if test -f $file;then # 相当于 if [ -f $file ];then
echo "执行:$file"
fi
done
问题shell脚本如何遍历文件夹下所有文件?
方法:
dir="./sql_to_hdfs_init"
for file in `ls $dir/*`
do
echo $file # 输出 ./sql_to_hdfs_init/a.sh
if test -f $file;then # 相当于 if [ -f $file ];then
echo "执行:$file"
fi
done
问题:如何判断subprocess.Popen运行的程序是否完成?
解决:通过ps aux可查看进程运行情况,如果命令已经完成,状态显示为:Z(僵尸进程)
方法:
# 查看进程12400的运行情况
ps aux | grep 12400
问题:如何实现jquery自动选中span文本
方法:
$('span').hover(function(){
var text = $(this)[0];
var selection = window.getSelection();
var range = document.createRange();
range.selectNodeContents(text);
selection.removeAllRanges();
selection.addRange(range);
}, function(){
var selection = window.getSelection();
selection.removeAllRanges();
});
问题:sqlalchemy新增数据到达梦,使用了synonym,使用了db.flush,但出现了代码新增的数据id与数据库新增的id不一致,导致新增数据完查询失败,报错:sqlalchemy.orm.exc.ObjectDeletedError: Instance '<College at 0x7fc16c5490d0>' has been deleted, or its row is otherwise not present
解决:直接删表,重新创建表,清除缓存可以使用db.refresh()代替db.flush()