I need to use a python script to modify the docstring of a function in another python script, and save it to a file overwriting
├── test.py
├── modify.py
# test.py 'Function file of docstring to be modified'
def hello_world():
"""
this function is a demo
mulit lines"""
return 'hello world'
"""
# This is an interference note and cannot be modified here
mulit lines"""
# modify.py 'Modify the docstring function of test.py'
from test import hello_world
def modify_docstring():
print(hello_world.__doc__) # this function is a demo
hello_world.__doc__ = 'I\' am new docstring'
print(hello_world.__doc__) # I' am new docstring # I can assign values in this way, but only in memory. How to modify and write the test.py file?