Having quotation marks as a character in a python list

user3731036

How do I put quotation marks in a list as an actual character?

Currently what I am doing is this:

pairings = ["A,#","B,6","C,+","D,""]

As you can see for 'D', I am making D equal to a quotation mark, however this is not possible as Python thinks it is an other value in a list. If I wanted to make D equal to " in this list how would I do this?

Ffisegydd

For strings in python you can use both single and double quoatation marks, ' and ". As such you can use one to have a string containing the other.

pairings = ['A,#','B,6','C,+','D,"']

I've modified all of the quotation marks to just use single, so it's consistent.

You can also escape quotation marks in strings using a backslash as below

s = 'This is my string, it contains a single quotation mark \', but that\'s fine because I\'ve escaped them!'

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Python regex: find and replace commas between quotation marks

분류에서Dev

Javascript quotation marks and commas

분류에서Dev

Issues with MySQL and quotation marks

분류에서Dev

shell commands with quotation marks in ranger

분류에서Dev

Reading non well-formed XML file without quotation marks in attribute - python

분류에서Dev

Where does this convention for quotation marks (`` ...'') come from?

분류에서Dev

Regular expression to find and replace wrong quotation marks

분류에서Dev

Bing search: Exact sentence with quotation marks

분류에서Dev

Quotation Marks breaking Flask-pagination

분류에서Dev

C# Regex to match a string that has double bars that are not in quotation marks

분류에서Dev

Using javascript: How can a variable be added to a string containing quotation marks?

분류에서Dev

Escape the square brackets and quotation marks or fetch this array without the quotes and brackets

분류에서Dev

How to tell Microsoft Word to not check spelling and grammar within quotation marks?

분류에서Dev

regex - How to match elements while ignoring others between quotation marks?

분류에서Dev

HTML symbol: Search for quotation marks from a page in Chrome

분류에서Dev

How do i get c# to write quotation marks when declaring a string?

분류에서Dev

comparing a list to a tuple, python 3.x - having problems getting the correct position to print

분류에서Dev

Python: encode special character

분류에서Dev

python script invalid character

분류에서Dev

How to call a list subset with a "character" object in R?

분류에서Dev

How to covert a character string into a list variable in R?

분류에서Dev

How to split a character vector based on length of a list

분류에서Dev

Python/Pygame character flashing rapidly

분류에서Dev

Python list to list of lists

분류에서Dev

Deleting of 'd' and 'n' character in strip in python

분류에서Dev

python add string return weird character

분류에서Dev

How to convert unicode to its original character in Python

분류에서Dev

Python reading file, error recognizing dot character

분류에서Dev

Python appending a list to a list and then clearing it

Related 관련 기사

  1. 1

    Python regex: find and replace commas between quotation marks

  2. 2

    Javascript quotation marks and commas

  3. 3

    Issues with MySQL and quotation marks

  4. 4

    shell commands with quotation marks in ranger

  5. 5

    Reading non well-formed XML file without quotation marks in attribute - python

  6. 6

    Where does this convention for quotation marks (`` ...'') come from?

  7. 7

    Regular expression to find and replace wrong quotation marks

  8. 8

    Bing search: Exact sentence with quotation marks

  9. 9

    Quotation Marks breaking Flask-pagination

  10. 10

    C# Regex to match a string that has double bars that are not in quotation marks

  11. 11

    Using javascript: How can a variable be added to a string containing quotation marks?

  12. 12

    Escape the square brackets and quotation marks or fetch this array without the quotes and brackets

  13. 13

    How to tell Microsoft Word to not check spelling and grammar within quotation marks?

  14. 14

    regex - How to match elements while ignoring others between quotation marks?

  15. 15

    HTML symbol: Search for quotation marks from a page in Chrome

  16. 16

    How do i get c# to write quotation marks when declaring a string?

  17. 17

    comparing a list to a tuple, python 3.x - having problems getting the correct position to print

  18. 18

    Python: encode special character

  19. 19

    python script invalid character

  20. 20

    How to call a list subset with a "character" object in R?

  21. 21

    How to covert a character string into a list variable in R?

  22. 22

    How to split a character vector based on length of a list

  23. 23

    Python/Pygame character flashing rapidly

  24. 24

    Python list to list of lists

  25. 25

    Deleting of 'd' and 'n' character in strip in python

  26. 26

    python add string return weird character

  27. 27

    How to convert unicode to its original character in Python

  28. 28

    Python reading file, error recognizing dot character

  29. 29

    Python appending a list to a list and then clearing it

뜨겁다태그

보관