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 is the basic basic knowledge of Python programming

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

Share

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

This article mainly explains "what are the basic basic knowledge of Python programming". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the basic basic knowledge of Python programming"?

1. Variables in Python

2. Python capitalization uses title () method, all uppercase upper () method, all lowercase lower () method.

3. Use the + sign for string concatenation in Python

4. Delete the space in the Python delete the rstrip () of the space at the end of the string, delete the lstrip () of the space at the beginning, and delete the strip () of the space at both ends.

5. The difference of print between Python2 and python3:

6. Integer operation in Python, using two multiplicative signs to denote multiplier operation

7. Avoid type errors in Python by using the str () function to convert values of other types into strings

8. Comments in Python

1. Variables in Python

Variable name: uppercase and lowercase, a combination of numbers and underscores, cannot start with a number

2. Python capitalization uses title () method, all uppercase upper () method, all lowercase lower () method.

> name='ce shi python'

> > name.title ()

'Ce Shi Python'

> > print (name.upper ())

CE SHI PYTHON

> > name2= "CE SHI PYTHON"

> > print (name2.lower ())

Ce shi python

3. Use the + sign for string concatenation in Python

> first_name='ce'

> > last_name= "shi"

> > full_name=first_name + last_name

> print (full_name)

Ceshi

> print ("Hello" + "" + full_name+ "" + 'roomeholders')

Hello ceshi welcome! Wuxi to see where to http://www.xasgfk.cn/ gynaecology

4. Delete the space in the Python delete the rstrip () of the space at the end of the string, delete the lstrip () of the space at the beginning, and delete the strip () of the space at both ends.

> > best_language= "python"

> > best_language = best_language.rstrip ()

> best_language

'python'

> > best_language = best_language.lstrip ()

> best_language

'python'

> > best_language= "python"

> best_language

'python'

> > best_language.strip ()

'python'

5. The difference of print between Python2 and python3:

There is no need to put what you want to print in parentheses in python2. Print in python3 is a function, so parentheses are essential; some python2's print also contain parentheses.

6. Integer operation in Python, using two multiplicative signs to denote multiplier operation

>

nine

> 10 years old 3

one thousand

7. Avoid type errors in Python by using the str () function to convert values of other types into strings

> age = 25

> message = "Happy" + str (age) + "Birthday!"

> message

'Birthdaytime Happy 25'

> print (message)

Happy 25 Birthday!

8. Comments in Python

Start with #, followed by comments

Thank you for your reading, the above is the content of "what is the basic basic knowledge of Python programming". After the study of this article, I believe you have a deeper understanding of the basic basic knowledge of Python programming, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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