开发者

Python splitting string. Need help

I'm trying to split a string into two different words. I have the following string:

test /

I want to split it so I can do

os.chdir('/')

I've tried different splitting techniques but they split by letter so it b开发者_如何学Cecomes

't','e','s','t', '', '/'


'test /'.split() will give you ['test', '/']. os.path.split() is for splitting paths and you might find it useful.


Splitting on a space isn't working? What are you trying to do eventually?

'test /'.split(' ')

or no parameters at all:

tst, path = 'test /'.split()
os.chdir(path)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜