In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to carry out Python string analysis, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
1.for re-implementation: 1, 2, 3... + 100mm?
Running result:
Python Code:
Click (here) to collapse or open
# use for to compute 1 / 2 / 3 / 3 / 100
Final=0
For i in range (1101):
Final=final+i
Print'1, 2, 3, 1, 2, 3, 1, 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3, 3, 2, 3, 3, 2, 3, 2, 3, 2, 3, 2, 3, print'1, 2, 3, 3, 2, 2, 3, 2, 2, 3, 2, 3, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 2, 2, 3, print', final.
Interpretation:
Range (1,101) means to start at 1 and end at 101 (excluding 101), taking all the integers in it.
Compared to yesterday's while, there is no longer the need for a single variable to record the number of cycles.
-*-
two。 String formatted output
Running result:
Code:
Click (here) to collapse or open
From random import randint
Num=randint (1100)
Print 'Guess what I think?'
Final=False
While final==False:
Answer=input ()
If answernum:
Print str (answer) +'is too bigger'
If answer==num:
Print "Good, you guess it! It's d." answer
Final=True
Two formatting methods:
1) str (): converts numbers to strings
2) format the string with%:
% d replace integers
% f replace decimal places (want to keep two decimal places,% .2f)
% s to replace a string
-*-
Add a basic knowledge: the use of strings
Running result:
Code:
Click (here) to collapse or open
Print 'Method 1, "Yiyi's mom."
Print 'Method 1 is a "good" baby.'
Print 'Method 2 What's your name? "Isimm Yiyi."''
Print 'Method 2 Iris Iris, "And you?"
Print 'Method 3 good I\' Ma\ "baby.'"
Print 'Method 3 is this is\
Same line.'
Knowledge points:
The most common string representations are single quotation marks ('') and double quotation marks (""): 'string' has the same effect as "string"
It must be English characters!
There are odd and double quotation marks in the output, what should I do? See the chestnut, can you see that there are three ways?
Question: what is it used for?
Click (here) to collapse or open
Print 'Well study,\ nwell think,\ nwell listen,\ n\
Well do,\ nwell speak\ n-- come onboarding'
Print'^ _ ^ @ _ @ * _ *'
Results:
The running version of the program:
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license ()" for more information.
After reading the above, do you have any further understanding of how to analyze Python strings? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.