9. 代码块
9.1. c++代码样例
#include <stdio.h>
int main(int argc, char* argv[]) {
printf("HelloWorld!);
return 0;
}
9.2. bash代码样例
#!/bin/sh
#================================================
#FileName : test.sh
#Author : wzx
#Description:
#DateTime : 2019-05-02 11:00:00
#Version : V1.0
#Other :
#================================================
for opt in "${@}"; do
case $opt in
--input-model=*)
export input_model="$(echo "$opt" | cut -d '=' -f 2-)"
;;
--input-picture=*)
export input_picture="$(echo "$opt" | cut -d '=' -f 2-)"
;;
--help)
echo ${USAGE_LINE}
exit
;;
*)
echo ${USAGE_LINE}
exit
;;
esac
done
9.3. python代码样例
try:
f = open('/path/to/file', 'r')
print(f.read())
finally:
if f:
f.close()
with open('/path/to/file', 'r') as f:
print(f.read())
f = open('/Users/michael/gbk.txt', 'r', encoding='gbk', errors='ignore')
9.4. json对象样例展示
{
"name": "BeJson",
"url": "http://www.bejson.com",
"page": 88,
"isNonProfit": true,
"address": {
"street": "科技园路.",
"city": "江苏苏州",
"country": "中国"
},
"links": [
{
"name": "Google",
"url": "http://www.google.com"
},
{
"name": "Baidu",
"url": "http://www.baidu.com"
},
{
"name": "SoSo",
"url": "http://www.SoSo.com"
}
]
}