Python Quick Tip: F-Strings - How to Use Them and Advanced String Formatting

preview_player
Показать описание
In this Python Programming Tutorial, we will be learning how to use f-strings to format strings. F-strings are new to Python3.6+ and are extremely useful once you learn how to use them. Viewers have likely seen me use f-strings in previous videos so this video will go into detail exactly how to use them so that everyone can follow along confidently. Let's get started...

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey's Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:

#Python
Рекомендации по теме
Комментарии
Автор

f string is god send. I am glad I started python in the post 3.6 era

sandeepvk
Автор

One cool use of f-strings can be to iterate over a dictionary where the keys are strings of integers for some reason (using a JSON dictionary for instance) and get the values out of it directly with integers. No need to add an extra step to convert to strings, just use an f-string!

Example:
>>> mydict = {'0': 30, '1': 12, '2': 6, '3': 11, '4': 20} # using strings as keys
>>> [mydict[f'{i}'] for i in range(4)] # list comprehension to retrieve values in dictionary based on integer
>>> [30, 12, 6, 11] # list of values retrieved

Hopefully someone will find that useful... or at least somewhat interesting :).

slavoie
Автор

I've been using f-strings for a while but never about the colon formatting "tricks" before this. Nice!

lalligood
Автор

Its amazing how short but absolutely clear and excellently explained your videos are. Thank you from South Africa

theegreatestever
Автор

Another excellent video from Corey Schafer. Easily the best python instructor on YouTube. I'll be switching to f-string from now on.

stuthomas
Автор

This is probably the best video I have seen explaining how F strings work. Thanks.

TheVerucAssault
Автор

Thanks Corey Schafer for f' string quick video explanation!

doruletu
Автор

Precise, informative and exact..how do you do this Corey?

noobinvestor
Автор

This was the first time I liked, subscribed and hit the bell icon before being asked. This explains #fstrings on an intuitive level. Well done with the comparisons as well!

ajkraftt
Автор

Hey Buddy ur videos are of top quality

SACHIN-gdzy
Автор

your english is clear, your teaching skills are amazing. Thanks!

lucasflores
Автор

I was introduced to f-strings today in John Zelle's Intro to Computer Science: Python Programming book, which is very good and has taught me the Python I know, so far. I wasn't grasping the concept as quickly as I expected from the book, which has been the only thing I haven't been able to grasp within a few days so I came here to your channel. This makes f-strings look so sexy. Thanks a lot!

WisomofHal
Автор

Wow! Came back to this video after letting f'strings mingle in my mind for a few weeks and this is even more golden haha. Really like the calculation exercise you showed uses f'string it's so cool Python allows us to run calculations within the {} Thanks again coach!

WisomofHal
Автор

Such a delightful feature! Thanks Corey.

srikanthspl
Автор

Thank you for the video. I am gratuful for your time and contribution. Kind regards, Akira.

akira_asahi
Автор

I am in Shanghai, China. Watching your video is very helpful. I am very interesting about Python.

kelue
Автор

this is similar to template literals in javascript, awesome. Thanks, bro!

dsuryas
Автор

I have followed your video and get courage to learn python.
Thanks god I have find you.
You are really a good guy. Thanks a lot.
Just carry on.

TechReptile
Автор

this video was very helpful. Thanks Corey!!

sampanicker
Автор

Helpful video, easy and to the point . Thanks mate

KakaTu