No, you can't apply slicing to strings inside a the replacement field.

You'll need to refer to the Format Specification Mini-Language; it defines what is possible. This mini language defines how you format the referenced value (the part after the : in the replacement field syntax).

Answer from Martijn Pieters on Stack Overflow
🌐
Python
docs.python.org › 3 › library › string.html
Common string operations — Python 3.14.7 documentation
It is exposed as a separate function for cases where you want to pass in a predefined dictionary of arguments, rather than unpacking and repacking the dictionary as individual arguments using the *args and **kwargs syntax. vformat() does the work of breaking up the format string into character data and replacement fields.
🌐
Real Python
realpython.com › python-string-formatting
Python String Formatting: Available Tools and Their Features – Real Python
December 1, 2024 - If you’ve ever worked with the printf() function in C, then the syntax will be familiar. Here’s a toy example: ... The %s substring is a conversion specifier that works as a replacement field.
🌐
W3Schools
w3schools.com › python › python_string_formatting.asp
Python String Formatting
Before Python 3.6 we had to use the format() method. ... F-string allows you to format selected parts of a string.
🌐
W3Schools
w3schools.com › python › ref_string_format.asp
Python String format() Method
Remove List Duplicates Reverse ... Python Interview Q&A Python Training ... The format() method formats the specified value(s) and insert them inside the string's placeholder....
🌐
Python Morsels
pythonmorsels.com › string-formatting
Python f-string tips & cheat sheets - Python Morsels
April 12, 2022 - The >N format specifier (where N is a whole number) right-aligns a string to N characters. Specifically, this formats the resulting substring to be N characters long with spaces padding the left-hand side of the string.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-substring-a-string-in-python
How to Substring a String in Python - GeeksforGeeks
July 23, 2025 - In this example, we are trying to extract the starting word from the string.we used string slicing to extract the substring "Geeks" from the beginning of the string. The slice notation str[:5] starts at index 0 (the first character) and goes up to, but does not include, index 5, resulting in "Geeks". ... In this example we are trying to extract the last portion of the string.we used string slicing to extract the substring "best!".
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › how-to-substring-a-string-in-python
How to Substring a String in Python
January 3, 2020 - This is often called "slicing". Here is the syntax: string[start:end:step] Where, start: The starting index of the substring. The character at this index is included in the substring.
🌐
Python
docs.python.org › 3.4 › library › string.html
6.1. string — Common string operations — Python 3.4.10 documentation
It is exposed as a separate function for cases where you want to pass in a predefined dictionary of arguments, rather than unpacking and repacking the dictionary as individual arguments using the *args and **kwargs syntax. vformat() does the work of breaking up the format string into character data and replacement fields.
🌐
Python Data Science Handbook
jakevdp.github.io › WhirlwindTourOfPython › 14-strings-and-regular-expressions.html
String Manipulation and Regular Expressions | A Whirlwind Tour of Python
One place where the Python language really shines is in the manipulation of strings. This section will cover some of Python's built-in string methods and formatting operations, before moving on to a quick guide to the extremely useful subject of regular expressions.
🌐
DataCamp
datacamp.com › tutorial › python-string-format
Python String format() Tutorial | DataCamp
October 23, 2020 - Adjust the strings so they are lowercase. Finally, print the variables first_pos and second_pos. # Assign the substrings to the variables first_pos = wikipedia_article[3:19].lower() second_pos = wikipedia_article[21:44].lower() When we run the above code, it produces the following result: ... Try it for yourself. To learn more about positional formatting, please see this video from our course, Regular Expressions in Python.
🌐
PyFormat
pyformat.info
PyFormat: Using % and .format() for great good!
With this site we try to show you the most common use-cases covered by the old and new style string formatting API with practical examples. All examples on this page work out of the box with with Python 2.7, 3.2, 3.3, 3.4, and 3.5 without requiring any additional libraries.
🌐
Learn Python
learnpython.org › en › String_Formatting
String Formatting - Learn Python - Free Interactive Python Tutorial
Your current balance is $53.44.", no_output_msg= "Make sure you add the `%s` in the correct spaces to the `format_string` to meeet the exercise goals!") test_object('format_string') success_msg('Great work!') This site is generously supported by DataCamp. DataCamp offers online interactive Python Tutorials for Data Science.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-use-string-formatters-in-python-3
How To Use String Formatters in Python 3 | DigitalOcean
This tutorial will guide you through some of the common uses of string formatters in Python, which can help make your code and program more readable and user…
🌐
GeeksforGeeks
geeksforgeeks.org › string-formatting-in-python
Python String Formatting - How to format String? - GeeksforGeeks
The format uses placeholder names formed by $ with valid Python identifiers (alphanumeric characters and underscores). Surrounding the placeholder with braces allows it to be followed by more alphanumeric letters with no intervening spaces.
Published: August 21, 2024
🌐
Google
developers.google.com › google for education › python › python strings
Python Strings | Python Education | Google for Developers
Characters and substrings can be accessed using zero-based indexing and the handy slice syntax. Python provides string methods for common operations like changing case, removing whitespace, and searching. String formatting, including f-strings and the older % operator, allows for controlled ...
🌐
Real Python
realpython.com › python-f-strings
Python's F-String for String Interpolation and Formatting – Real Python
November 30, 2024 - Python f-strings offer a concise and efficient way to interpolate variables, objects, and expressions directly into strings. By prefixing a string with f or F, you can embed expressions within curly braces ({}), which are evaluated at runtime. This makes f-strings faster and more readable compared to older approaches like the modulo (%) operator or the string .format() method.