我不认为 PyCharm 有这个功能,因为它不会真的是 Python。您可以执行以下操作:在first_script.py:from second_script import my_function# define certain variables with given some inputx = input()y = input()# ...# call 'my_function', which is defined in 'second_script.py'result = my_function(x, y)在文件中second_script.py:# define a function to process the variables and return somethingdef my_function(x, y): # process the variables z = x + y # and return the result return z这两个文件first_script.py都second_script.py应该在同一个目录中。然后你必须配置 PyCharm 以便它执行first_script.py。