【发布时间】:2016-03-16 16:47:17
【问题描述】:
正如题目所说..
我想使用该文件
indata.txt:
f=lambda x,y:-2*x*y
xa=0
xb=2
A=2
n=18
进入我的大计划:
from math import *
'''Function which calculates the d.e. using runge-kuttas formula'''
def runge(f,xa,xb,A,n):
.....
indata=open("indata.txt","r")
runge(f,xa,xb,A,n)
indata.close()
所以我的问题是: 如何使用文本文件 indata.txt 中的变量作为更大程序的输入?
【问题讨论】:
-
看起来像 python,为什么不直接调用它
indata.py并导入它? -
这是python,抱歉没有提及。该项目要求它是一个文本文件
-
您仍然可以通过文件名导入它,请参阅我链接的欺骗。
标签: python input text-files var