SyntaxError: unexpected EOF while parsing
1.源代码与错误
'''
5.编程求解1-4这4个数字可以组成多少个无重复的三位数,按从小到大的顺序输出这些数字。
analyze:
判断条件是 无重复是出口,三个数都可以产生1234,分为三层吗?还是分为个十百。
'''
count = 0
for i in range(1,5):
for j in range(1,5):
for k in range(1,5):
if i != j & j != k & k != i:
s = 100*i+10*j+k
count += 1
print('number is {},count is {:.0d}.'.format(s, count)
错误如下:
runfile('C:/Users/caotong/.spyder-py3/ctt_python_study_aboutData/Unit2-test_5About1234.py', wdir='C:/Users/caotong/.spyder-py3/ctt_python_study_aboutData')
File "C:\Users\caotong\.spyder-py3\ctt_python_study_aboutData\Unit2-test_5About1234.py", line 20
print('number is {},count is {:.0d}.'.format(s, count)
^
SyntaxError: unexpected EOF while parsing
在下,蠢笨分析一下:
SyntaxError 翻译 :语法错误
EOF 翻译:End of File
parsing 翻译:解释器
解释器在文件结束都没找到他所期待的东西。
format 格式化函数函数出现了语法问题,更正如下:老天爷,最后发先是最后差了了括号!
print(‘number is {} ; count is {}.’.format(s, count))