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

How does python print a string

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to print strings in python". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Strings are the most commonly used data type in Python. Quotation marks ('or') can be used to create strings.

I. print string

1. Converting strings _ is mainly used in the conversion operation of print function and string function str

2. Output reprinters _ applies to all output operations. If there are print and str operations and _ _ str__, is defined, the _ _ str__ will prevail.

3. When the output reprinters _ and _ _ str__ are not defined, the output object address information is printed by default.

II. Examples

# str.pyclass DisplayClass: "_ repr__ is used everywhere, except by print and str when a _ str__ is defined. _ _ str__ to support print and str exclusively "" def _ _ repr__ (self): return "display _ repr__ class" def _ str__ (self): return "display _ str__ class" # printout 2.x & 3.x output in the form of command line Take 2.x as screenshot > d = DisplayClass () > > d # call repr > print (d) # call str > print (repr (d)) # call repr > print (str (d)) # what are the main applications of calling strpython 1. Cloud computing Typical application OpenStack.

2. WEB front-end development, many large websites are developed by Python.

3. Artificial intelligence applications, which are based on big data's analysis and deep learning, have essentially been unable to leave python.

4. System operation and maintenance project, the standard configuration of automatic operation and maintenance is python+Django/flask.

5. Financial management analysis, quantitative transaction, financial analysis.

6. Big data's analysis.

This is the end of "how to print strings in python". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Development

Wechat

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

12
Report