Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在函数中创建变量,然后通过导入该脚本并在单独的脚本中运行该函数来使用该函数?
一个.py
def function_to_use(数据): use_var = 数据 返回 use_var
b.py
从导入函数_to_use 如果 __name__ == '__main__': 打印 function_to_use(6)