Created
September 21, 2024 22:18
-
-
Save pamelafox/f8e4b62b03d48ed0961a415a30efd1be to your computer and use it in GitHub Desktop.
Python 3.12 f strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print python version | |
import sys | |
print(sys.version) | |
import math | |
if True: | |
wow = f"""this is a multiline f string with triple quotes {math.pi:0.2f} : | |
1. Line 1 | |
2. Line 3 {math.pi:0.2f}""" | |
indent = f"""this is a multiline f string with triple quotes {math.pi:0.2f} : | |
1. Line 1 | |
2. Line 2""" | |
woa = f"this is a multiline f string with double quotes {1 # wow math is so cool | |
+ 2 | |
+ 3}" | |
#not_allowed = f"this wont work! {math.pi:0.2f} : | |
# 1. Line 1" | |
print(wow) | |
print(indent) | |
print(woa) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment