摘要: select * from 表名 limit 1; 阅读全文
posted @ 2021-07-13 18:56 lucky_tomato 阅读(6631) 评论(0) 推荐(0) 编辑
摘要: 正序 select 字段 from 表名 order by 排序字段; 倒序 select 字段 from 表名 order by 排序字段 desc; 阅读全文
posted @ 2021-07-13 18:20 lucky_tomato 阅读(271) 评论(0) 推荐(0) 编辑
摘要: 在平常编写Python脚本的时候,可能需要指定退出状态码,然后来进一步判断,实现方法如下: import sys if not os.path.exists('/usr/local/nginx'): print_warn("不存在/usr/local/nginx") sys.exit(1) #这里指 阅读全文
posted @ 2021-07-13 15:18 lucky_tomato 阅读(619) 评论(0) 推荐(0) 编辑
摘要: Django会用到values_list()和values()方法,他们之间不同,如下: 例子: job_data = ops_manage.Install_Cross_Task.objects.filter(task_status=0) job_id = job_data.values_list( 阅读全文
posted @ 2021-07-13 15:10 lucky_tomato 阅读(332) 评论(0) 推荐(0) 编辑
摘要: 在写Python脚本时,我们可能希望从另一个脚本里面导入变量,分享下方法 文件A名为test1.py,变量名为localhost_hostname localhost_hostname = run_cmd("cat /etc/host_name")[1] 文件B名为test2.py,需要使用到文件A 阅读全文
posted @ 2021-07-13 10:41 lucky_tomato 阅读(2177) 评论(2) 推荐(0) 编辑