我看过python-mode和python.el.我正在使用python-mode.el.我也在使用绳索和绳索.我正在寻找关于这些的一些文档,这些文档可以帮助我,或者其他elisp软件包或其他东西.
我目前的问题是我给出的代码具有不一致的缩进大小.对于一些块,它将是两个,对于一些它将是4.我想要清理它,但出于某种原因,当我告诉emacs"修复缩进"时,它只是基本上击中每一行的选项卡,这搞砸了代码.我想要的是保持相同的相对缩进,但标准化为4个空格.有什么能让我轻松做到这一点吗?
我想我可以找到每个坏缩进的实例,阻止它,并用4个空格查询替换2个空格.但这对我的精确度有点过分依赖,注意到应该在哪里完成.此外,它是很多代码.
有人告诉我,自行车修理工会解决这个问题,但现在几年已经没有开发......还有其他任何建议吗?
谢谢.
嗨,我是python新手,我正在使用python工作NLP.我在写python中的if-else块时遇到错误.当我写作时,只有当时阻止它正常工作:
if xyzzy.endswith('l'):
print xyzzy
Run Code Online (Sandbox Code Playgroud)
进入冒号后,我按下回车键,它会自动将我带到正确的缩进处.
但是当我在print语句后按"Enter"键后尝试添加else块时,它正在考虑它只是IF块的声明,所以它给了我不正确的缩进,因为我想要阻止之后,而当我我试图写别阻止我的自我它给了我这个错误.
else:
^
Run Code Online (Sandbox Code Playgroud)
IndentationError: unexpected indent
那么在写完print语句后我该怎么办?输入显然不起作用,因为它正在向前移动光标,而当我使用空格来到正确的指针时它会给我一个错误.
我无法正常使用python,因为Sublime text 2正在删除缩进.如果我添加并编辑文档的另一部分,ST将再次删除所有表格.显然python会抛出错误:IndentationError:意外的缩进.
我该怎么调整呢?
我对 Notepad++ 的 Python 缩进有很多问题。为了解决,我尝试安装 Python reindent 模块,但我不知道如何使用它。如果有人成功了,请告诉我..
这是我尝试的步骤。
1.使用简易安装我尝试安装包,
C:\Python27\Scripts>easy_install reindent
Searching for reindent
Reading http://pypi.python.org/simple/reindent/
Best match: Reindent 0.1.1
Downloading http://pypi.python.org/packages/source/R/Reindent/Reindent-0.1.1.tar
.gz#md5=878352c36c421a0b944607efba3b01ad
Processing Reindent-0.1.1.tar.gz
Running Reindent-0.1.1\setup.py -q bdist_egg --dist-dir c:\users\premvi~1\appdat
a\local\temp\easy_install-qdahih\Reindent-0.1.1\egg-dist-tmp-1z1zw8
zip_safe flag not set; analyzing archive contents...
Adding reindent 0.1.1 to easy-install.pth file
Installing reindent script to C:\Python27\Scripts
Installed c:\python27\lib\site-packages\reindent-0.1.1-py2.7.egg
Processing dependencies for reindent
Finished processing dependencies for reindent
Run Code Online (Sandbox Code Playgroud)
当我在 python GUI 上执行导入命令时,它成功了。
当我尝试使用它时出现以下错误。
>>> import reindent
>>> reindent -d c:/python27/wxpython/ch2-updateui.py
SyntaxError: invalid syntax
>>> reindent -d …Run Code Online (Sandbox Code Playgroud) (我是初学者)Python通常使用缩进来指定代码行的嵌套级别.有没有其他方法可以做到这一点?
import os
import sys, urllib2, urllib
import re
import time
from threading import Thread
class testit(Thread):
def __init__ (self):
Thread.__init__(self)
def run(self):
url = 'http://games.espnstar.asia/the-greatest-odi/post_brackets.php'
data = urllib.urlencode([('id',"btn_13_9_13"), ('matchNo',"13")])
req = urllib2.Request(url)
fd = urllib2.urlopen(req, data)
<TAB>fd.close()
<TAB>"""while 1:
data = fd.read(1024)
if not len(data):
break
sys.stdout.write(data)"""
url2 = 'http://games.espnstar.asia/the-greatest-odi/post_perc.php'
data2 = urllib.urlencode([('id',"btn_13_9_13"), ('matchNo',"13")])
req2 = urllib2.Request(url2)
fd2 = urllib2.urlopen(req2, data2)
<TAB>#prints current votes
while 1:
data2 = fd2.read(1024)
if not len(data2):
break
sys.stdout.write(data2)
<TAB>fd2.close()
print time.ctime()
print " ending …Run Code Online (Sandbox Code Playgroud)