Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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 becomes
't','e','s','t', '', '/'
list("test /")
str.split()
'test /'.split() will give you ['test', '/']. os.path.split() is for splitting paths and you might find it useful.
'test /'.split()
['test', '/']
os.path.split()
Add a comment
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)
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
list("test /")Try looking at thestr.split()method