FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
senior-python-engineer/python_core/string_template.py at main · Rustam-Z/senior-python-engineer · GitHub
Rustam-Z
/
senior-python-engineer
Public
Notifications
You must be signed in to change notification settings
Fork
41
Star
163
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
senior-python-engineer
/
python_core
/
string_template.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
15 lines (10 loc) · 432 Bytes
Breadcrumbs
senior-python-engineer
/
python_core
/
string_template.py
Copy path
File metadata and controls
15 lines (10 loc) · 432 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""
- Use Template when you just want to substrings the values, you don't need formatting.
- Templates are secure compared to .format()
https://www.geeksforgeeks.org/template-class-in-python/
"""
from
string
import
Template
students
=
[(
'Ram'
,
90
), (
'Ankit'
,
78
), (
'Bob'
,
92
)]
template
=
Template
(
'Hi $name, you have got $marks marks'
)
for
student
in
students
:
print
(
template
.
substitute
(
name
=
student
[
0
],
marks
=
student
[
1
]))
Back
|
FazBrowse Home
|
New Git URL