python--string manipulation

Source: Internet
Author: User

##-*-coding:utf-8-*-" "Created on December 31, 2017 @author:soyo" "Str="I learn python and learn Spark"PrintSTR, str[0],str[-1] PrintStr[:6]#Slicing OperationsStr2="I like ' Spark '"Printstr2#function of "\": Cancel Wrapstr3="""Python has a rich library, \ Use a wide range of uses. The most common is the use of machine learning. But ' Spark ' is strong, too.""" PrintSTR3#Special character HandlingPrint "E:\note\Python.doc"      #\ n changes to line breakPrintR"E:\note\Python.doc"     #+r ProcessingPrint '-'*50Print "String Formatted output"FORMAT_STR5="there is {0} apples {1} The Windows". Format (2," on")PrintFORMAT_STR5Print '-'*50Print "string method uses"Print "***************"STR5="5789610"Print "generates a new string with the specified delimiter connection"Print ">". Join (STR5)Print "string All uppercase"      PrintStr.upper ()Print "the number of ' learn ' in the statistics string"PrintStr.count ("Learn")PrintStr.replace ("Learn","Learn_soyo")

Results:

I learn python and learn Spark i k
I lear
I like ' Spark '
Python has a rich library, \
The use of the application is very wide. The common thing is to
use of machine learning. But ' Spark ' is strong, too.
E:
Ote\python.doc
E:\note\Python.doc
--------------------------------------------------
String Formatted output
There is 2 apples on the windows
--------------------------------------------------
string method uses
***************
generates a new string with the specified delimiter connection
5>7>8>9>6>1>0
string All uppercase
I Learn PYTHON and learn SPARK
the number of ' learn ' in the statistics string
2
i Learn_soyo python and Learn_soyo Spark

python--string manipulation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.