Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

11 12 13 14 py single quote string, double quote string and escape

Shulou Source: shulou.com Published: 2022-06-03 07:45:49 09月30日 Update

Lesson 11 Single quote strings, double quote strings, and escape characters #Single quote strings, double quote strings, and escape characters print ('Hello World') print ('Hello World') print ('Let's go! ")print ('"OK"')print ('H',\"W\")-------------------------- "OK"'H',"W"//There is no essential difference between single quotation marks and double quotation marks in py, but print is used to highlight the respective symbols.("hello 'world'")print ('hello "world"')--------------------hello 'world'hello "world" What if we want to print both single and double quotes?("hello,'w'\"o\"rld") The output result is hello,'w'"o"rld----------------------------------------------("Hello", "world","Hello World")x = "Hello"y = "World"print (x + y + x)----------------------------------------------- #indicates world to next line print (str(1234) + "\n" + str(4321))#We want to output\n as it is. There are 3 methods #Method 1: Use repr function print (repr("Hello\nWorld"))#Method 2: Output\print using escape characters ("Hello\\nWorld")#Method 3: Prefix the string with rprint (r"Hello\nWorld")----------------------------------------Lesson 14 Long String #Long String '''""""print(""Hello World"") print("" HelloABC "")print("Hello \\World")-----------------------------

Tags: Character string quotation mark output method result escape original flavor hello world original flavor original juice ordinary one line three stresses function original at the same time summary how to do Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker Huawei vpn NVidia