最近开始学习python,对比shell做一些比较:
Shell:
0 1 2 3 4 5 6 7 8 9 10 |
#!/bin/bash # Author:Byrd # Version:0.1 # Site:note.t4x.org # Contact:root#t4x.org a=100 if [ $a -ge 0 ]; then echo $a else echo "-$a" fi |
备注:-gt表示大于或者等于,具体请man test
Python
0 1 2 3 4 5 6 7 |
#!/usr/bin/env python # Author: Byrd # Created Time: Tue 20 Dec 2016 02:20:07 PM CST a = 100 if a >= 0: print(a) else: print(-a) |
备注:当语句以:结尾时候,缩进的语句视为代码块 SourceByrd's Weblog-https://note.t4x.org/code/first-python-diff-shell/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!