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 to use Python from _ _ future__ import print_function

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

Share

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

This article mainly introduces "how to use Python from _ future__ import print_function". In daily operation, I believe many people have doubts about how to use Python from _ future__ import print_function. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to use Python from _ future__ import print_function"! Next, please follow the editor to study!

After adding the sentence from _ _ future__ import print_function at the beginning, even in python2.X, you have to use print in parentheses like python3.X. Parentheses are not required for print in python2.X, but are needed in python3.X.

# python2.7

Print "Hello world"

# python3

Print ("Hello world")

If a new feature appears in a version, and it is not compatible with the one used in the current version, that is, it is not a language standard in that version, then I need to import it from the future module if I want to use it.

Other examples:

From _ _ future__ import division

From _ _ future__ import absolute_import

From _ _ future__ import with_statement . Wait

Plus these, if your version of python is python2.X, you have to use these functions as python3.X does.

At this point, the study on "how to use Python from _ future__ import print_function" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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