a file content just like this:
##this is the comment
but this is not comment '####', LOL # this is a normal comment
I just want to filter all comments and get the filtered content, But I don’t know how to avoid to filter the pound signs which are not comments.
fileLines = [line.strip() for line in file if '#' != line[0] ]
this code just can filter the comment sign which is the first character of a line.
the result I want is just like the following line:
but this is not comment '####', LOL
See the shlex docs for more information.