Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created September 21, 2024 22:18
Show Gist options
  • Save pamelafox/f8e4b62b03d48ed0961a415a30efd1be to your computer and use it in GitHub Desktop.
Save pamelafox/f8e4b62b03d48ed0961a415a30efd1be to your computer and use it in GitHub Desktop.
Python 3.12 f strings
# 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