Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

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")-----------------------------

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report