In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how Python implements input and output, Xiaobian thinks it is quite practical, so share it for everyone to make a reference, I hope you can gain something after reading this article.
input() input
Python provides the input() built-in function to read a line of text from standard input, which is the keyboard by default. input can take a Python expression as input and return the result.
Please enter: Gas station on the code You entered: Gas station on the code
Execution inputs:
Please enter: Code on the gas station You enter: Code on the gas station print() Output
print() function. If you want more variety in the output, you can format the output value using str.format(). See more examples below;
Hello, pythonHello, python'Hello, python' constant PI is approximately 3.141592653589793. I and you pay attention to [gas station on the code] to learn python together Pay attention to [gas station on the code], enter python to get the value of the learning guide constant PI is approximately 3.14. The value of the constant PI is approximately 3.142. 00012-003.14
Output:
Hello, pythonHello, python'Hello, python' constant PI is approximately 3.141592653589793. I and you pay attention to the code on the gas station together to learn python attention to the code on the gas station, enter python to get the value of the learning guide constant PI is approximately 3.14. The value of the constant PI is approximately 3.142. 00012-003.14pprint() Output
print() and python print () are both python print modules with basically the same function.
The only difference is that the data structure printed by the pprint() module is more complete, each line is a data structure, which is more convenient to read the printout. Especially for very long data printing, print() output results are in one line, inconvenient to view, and pprint() uses branch print output, so for data structure is more complex, data length is longer, suitable for pprint() printing mode.
Print() is usually used.
import pprintdef main(): data = ( "this is a string", [1, 2, 3, 4], ("more tuples", 1.0, 2.3, 4.5), "this is yet another string" ) pprint.pprint(data)if __name__ == "__main__": main()
Output;
('this is a string',[1, 2, 3, 4],('more tuples', 1.0, 2.3, 4.5), 'this is yet another string') About "Python how to achieve input and output" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.