开发者

Using if-condition to check filename

开发者 https://www.devze.com 2022-12-19 04:47 出处:网络
I\'m doing a real silly mistake in Python but unable to find what it is I\'m doing something like this in python

I'm doing a real silly mistake in Python but unable to find what it is

I'm doing something like this in python

filename="file1"
if name == 'file1'
    print 1

I'开发者_开发知识库m getting an invalid syntax error


You are missing a colon

filename="file1"
if name == 'file1':
    print 1


You need to put a colon at the end of the if statment

filename="file1"
if name == 'file1':
    print 1


what is name?? did you define it elsewhere?? I assume its "filename" instead, so

filename="file1"
if filename == 'file1':
    print 1

if "name" is defined, then the problem is indeed the ":" at the end of "if" line.

0

精彩评论

暂无评论...
验证码 换一张
取 消