【发布时间】:2014-08-17 14:46:12
【问题描述】:
我正在编写一个带有文本的 python,输出都是字符串,我没有上传任何库,我试图在我的文本中使用这个条件
f.write("G3")
f.write(" ")
i = raw_input("enter the G3 for wind J or K = ")
for i:
if i=J
f.write(i)
f.write(" ")
f.write("CDS1")
a = raw_input("alter the CDS1 = ")
f.write(a)
f.write(" ")
f.write("DELTA")
d = raw_input("alter the DELTA = ")
f.write(d)
f.write(" ")
f.write("AGROW")
f.write("\n")
else i = K
f.write(i)
f.write(" ")
f.write("A")
f.write("\n")
f.write("WCAP K")
f.write("\n")
我明白了
for i:
^
SyntaxError: invalid syntax
我写对了吗?还是我遗漏了什么?
【问题讨论】:
-
我认为你需要看看 for 循环语法:docs.python.org/3.4/reference/compound_stmts.html#for
-
用文本写python?
-
@salmanwahed 是的,它基本上是为了自动化而被合并到一个更大的脚本中,这是可能的,如果你有大文件,它可以省去你从头开始编写代码的麻烦