简体   繁体   中英

I want replace single quotes with double quotes in a list

i need convert list items ' convert "

thislist = ["apple", "banana", "cherry"]
print(thislist)

result

['apple', 'banana', 'cherry']

i want this

["apple", "banana", "cherry"]

but the variable must be a list, not a string.

A string as a sequence of characters not intended to have numeric value. In Python, such sequence of characters is included inside single or double quotes.

As far as language syntax is concerned, there is no difference in single or double quoted string. Both representations can be used interchangeably.

However, if either single or double quote is a part of the string itself, then the string must be placed in double or single quotes respectively.

str1='Hello "Python"'

equivalent to

Str2="Hello 'Python'"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM