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

What are the ways to use print in python

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you what is the use of print in python, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The print function is used to print and output code content

1. The output of the print () function: numbers, strings, expressions containing operators.

# numeric print (520) print (98.5) # string print ('helloworld') print (helloworld) # Note that when there are no quotation marks, there is a variable output instead of the string # (the helloworld variable output here, there is no definition of errors when using the direct runtime) # expression print with operations (3x1)

2. The output destination of the print () function: display screen, a certain folder.

# when you directly use the print () function, the output is on the display screen. # output the data to the file as follows: fp=open ('hello world',file=fp text. Txt files)) # define fp to open the file, and a + means to create the file without, and append the print (' hello world',file=fp) # input function to the file (file), that is, fp.close () in the file opened by fp # close the open file

3. The output form of the print () function: line breaks, no line breaks.

# No line wrapping is to write down the output print ('hello','python','world') on the same line. These are all the contents of this article entitled "how to use print in python?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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