Python
Windows 7
>>> s="中国路13号弄"
>>> s.find("号")
8
>>> print s[:8]
中国路13
MAC OSX10.9.2
>>> s="中国路13号弄"
>>> s.find("号")
11
>>> print s[:11]
中国路13
Shell
Linux CentOS
从pos开始截取num个,不包含pos位置
${str:pos:num}
从pos开始截取l个字符,包含pos位置
expr substr "$str" 2 $num
忽略特殊字符
使用单引号 ' '
rm -rf 'fo o' 忽略了空格
cut 按字符的形式获取前3个字符
echo $str | cut -c -3