How to remove quotes from string in Python

3 Answers

0 votes
s = '"python"'

new_string = s.replace('"', '')

print("{}".format(s))
print("{}".format(new_string))

  
  
  
'''
run:
  
"python"
python

'''

 



answered Apr 13, 2021 by avibootz
0 votes
s = '"python"'

new_string = s.strip('"')

print("{}".format(s))
print("{}".format(new_string))

  
  
  
'''
run:
  
"python"
python

'''

 



answered Apr 13, 2021 by avibootz
0 votes
s = '"python"'

new_string = eval(s)

print("{}".format(s))
print("{}".format(new_string))

  
  
  
'''
run:
  
"python"
python

'''

 



answered Apr 13, 2021 by avibootz
...