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?
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] 삭제
몇 마디 만하겠습니다