Problem getting last characters until find "" character?
Question:
Hi i don’t know how to do this, in this example i want to get all the last characters until i find the "" character, usually in this way works but it seems that typing "" inside the split function doesn’t work and the program gives me an error. So how to get all the last characters until i find the "" starting from the end?
string = 'C:usercomputermyfile.txt'
a = string.split('')
Answers:
Escape your string with ”:
string = 'C:\user\computer\myfile.txt'
a = string.split('\')
print(a)
# Output
['C:', 'user', 'computer', 'myfile.txt']
Hi i don’t know how to do this, in this example i want to get all the last characters until i find the "" character, usually in this way works but it seems that typing "" inside the split function doesn’t work and the program gives me an error. So how to get all the last characters until i find the "" starting from the end?
string = 'C:usercomputermyfile.txt'
a = string.split('')
Escape your string with ”:
string = 'C:\user\computer\myfile.txt'
a = string.split('\')
print(a)
# Output
['C:', 'user', 'computer', 'myfile.txt']