python技巧-使用os.path.join和os.path.sep.join

weixin_34413065發表於2018-11-16
2540794-fcfb96926197b75f.png
image.png
%timeit os.path.sep.join(['a','b'])
os.path.sep.join(['a','b'])
The slowest run took 5.00 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 238 ns per loop
'a/b'
%timeit os.path.join('a','b')
os.path.join('a','b')
The slowest run took 10.76 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 643 ns per loop
'a/b'

相關文章