How to enter single quotes in Python?
Sometimes when we print a string to the screen, the string may contain single quotes. How to achieve this? Two solutions
The first one: put single quotes inside double quotes
For example
print("H's my good friend!")
print("I really like 'python'!")
Output result
Through the above example, you can see that single quotes have been used by us
Second: Use escape characters
Python itself uses \ to escape some special characters, especially when quotation marks are added to the string
For example
print('H\'s my good friend!')
print('I really like \'python\'!')
Output result
The above is the detailed content of How to type single quotes in python. For more information, please follow other related articles on the PHP Chinese website!