我的 python 脚本中的标识有时会突然变成,我想你可以说是损坏了。标识会突然改变,使我的程序失败。
如果我使用 cat 查看文件,我可以看到标识是错误的。但在 VIM 中它显示得很好。这是输出和设置,
有任何想法吗 ???
通过'cat -e'
              validate_hostname = RegexValidator(regex=r'[a-zA-Z0-9-_]*\.[a-zA-Z]{2,6}',message="Enter a valid hostname.")$
           validate_hostname(host_input)$
   except ValidationError, e:$
               print type(e)$
       print str(e[0])$
       error = str(e)$
else:$
       error = "Please complete all fields."       $
   $
   print error$
   return [error,host_input,record_input]$
在 VIM 中,
                   validate_hostname = RegexValidator(regex=r'[a-zA-Z0-9-_]*\.[a-zA-Z]{2,6}',message="Enter a valid hostname.")
                   validate_hostname(host_input)
           except ValidationError, e:
               print type(e)
               print str(e[0])
               error = str(e)
       else:
           error = "Please complete all fields."
       print error
       return [error,host_input,record_input]
我的.vimrc看起来像,
syntax on
se bg=dark
set tabstop=4      " insert 4 spaces when a tab is pressed
set shiftwidth=4   " change the number of space characters inserted for indentation
set expandtab      " insert spaces whenver a tab key is pressed