python function ②

Processing to insert an arbitrary character string into a fixed phrase

format method

** String.format (argument, argument, ...) **

ex) >>> a ='{} has the same meaning as {}'

a.format ('immediately','immediately') 'Immediately the same as immediately'

# # ** String.format (0 arguments, 1, ...) ** By numbering, the same value can be displayed many times.    ex) >>> a ='{0} has the same meaning as {1}. {0} and {1} have the same meaning as {2}'

a.format ('immediately','immediately','immediately') 'Immediately has the same meaning. Immediately and immediately has the same meaning as'immediately'

# #

replace method

Find the old string in the string, create a string replaced with the new string, and return it ** String.replace (old string, new string) **

ex) >>> guest ='Saito, Suzuki, Tanaka'

guest.replace (',', like,') ** Mr. Saito, Mr. Suzuki, Mr. Tanaka

** String.replace (old string, new string, number of times) ** Searches the old character string from the character string for the specified number of times, creates a character string replaced with the new character string, and returns it.    ex) >>> guest ='Saito, Suzuki, Tanaka'

guest.replace (',', like,', 1) ** Mr. Saito, Suzuki, Tanaka

Recommended Posts

python function ①
[Python] function
python function ②
Python> function> Closure
[Python] Generator function
Python function decorator
About function arguments (python)
Function execution time (Python)
Python
Python function argument summary
Python print function (sequel)
Python: About function arguments
Time floor function (Python)
Create a function in Python
Use callback function in Python
[python] Value of function object (?)
ntile (decile) function in python
About python beginner's memorandum function
About the enumerate function (python)
python url setting include function
Python #function 2 for super beginners
Nonlinear function modeling in Python
Draw implicit function in python
Python higher-order function (decorator) sample
Immediate function in python (lie)
Call a Python function from p5.js.
Python basics ⑤
python + lottery 6
Python Summary
Built-in python
Python comprehension
Python technique
Studying python
Implement R's power.prop.test function in python
Python 2.7 Countdown
Python memorandum
Python FlowFishMaster
Python service
python tips
Function argument type definition in python
Python basics
Included notation in Python function arguments
ufo-> python (3)
Python comprehension
install python
Python Singleton
python memo
Python Jinja2
atCoder 173 Python
Python installation
Write AWS Lambda function in Python
python tips
Installing Python 3.4.3.
Try python
Python memo
Python algorithm
Python2 + word2vec
[Python] Variables
Python functions
Python sys.intern ()
Python tutorial