##-*-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