ZhangZhihui's Blog  
>>> header = "Say hello in Python"
>>>
>>> def hello(name: str) -> str:
...     """
...     %s
...
...     Python is amazing!
...     """
...     return f"Hello {name}. Nice to meet you!"
...
>>> hello.__doc__ %= header
>>> help(hello)
Help on function hello in module __main__:

hello(name: str) -> str
    Say hello in Python

    Python is amazing!

>>>

 

 

Python supports three different methods of string interpolation. Here they are:
• Using the %s method (the oldest)
• Using the format() string method
• Using f-strings

 

posted on 2023-07-28 17:21  ZhangZhihuiAAA  阅读(442)  评论(0编辑  收藏  举报