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)
精彩评论