擅长:python、mysql、java
<p>Python附带了<a href="http://docs.python.org/library/os.path.html" rel="nofollow">^{<cd1>}</a>模块,它为您提供了更好的处理路径和文件名的工具:</p>
<pre><code>>>> import os.path
>>> p = "E:/test/my_code/content/dir/disp_temp_2.hgx"
>>> head, tail = os.path.split(p)
>>> tail
'disp_temp_2.hgx'
>>> os.path.splitext(tail)
('disp_temp_2', '.hgx')
</code></pre>