简体   繁体   English

在Anaconda中设置Python缩进

[英]Set a Python indent in Anaconda

So I've got a problem. 所以我遇到了问题。 I installed Anaconda with Python 3.5.2 and when I go for cmd>python then interpreter is on, and then when I try: 我使用Python 3.5.2安装了Anaconda,当我选择cmd>python解释器打开,然后当我尝试时:

for i in range(10):
    print(i)

Then a message pops out (when I press TAB): 然后弹出一条消息(当我按TAB时):

Readline internal error
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\pyreadline\console\console.py", line 768, in hook_wrapper_23
    res = ensure_str(readline_hook(prompt))
  File "C:\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 571, in readline
    self._readline_from_keyboard()
  File "C:\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 536, in _readline_from_keyboard
    if self._readline_from_keyboard_poll():
  File "C:\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 556, in _readline_from_keyboard_poll
    result = self.mode.process_keyevent(event.keyinfo)
  File "C:\Anaconda3\lib\site-packages\pyreadline\modes\emacs.py", line 243, in process_keyevent
    r = self.process_keyevent_queue[-1](keyinfo)
  File "C:\Anaconda3\lib\site-packages\pyreadline\modes\emacs.py", line 286, in _process_keyevent
    r = dispatch_func(keyinfo)
  File "C:\Anaconda3\lib\site-packages\pyreadline\modes\basemode.py", line 257, in complete
    completions = self._get_completions()
  File "C:\Anaconda3\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions
    r = self.completer(ensure_unicode(text), i)
  File "C:\Anaconda3\lib\rlcompleter.py", line 80, in complete
    readline.redisplay()
AttributeError: module 'readline' has no attribute 'redisplay'

It's okay when I go for 2 spaces though. 虽然我去了2个空间,但没关系。 Can I set Anaconda to accept TAB indents as well? 我可以设置Anaconda接受TAB缩进吗?

It looks like the tab key performs a different function indentation. 看起来tab键执行不同的函数缩进。 It is mapped to "redisplay". 它被映射到“重新显示”。 I think you'll either have to change the config to allow tab indentation or use spaces. 我想你要么必须改变配置以允许标签缩进或使用空格。

for i in range(10):press Enter ... print(i)--- between last dot and p, insert three spaces and hit Enter. 对于范围内的i(10):按Enter键... print(i)---在最后一个点和p之间,插入三个空格并按Enter键。 In the next line there will be three dots and the (blinking) cursor is one space after the last dot. 在下一行中将有三个点,并且(闪烁)光标是最后一个点之后的一个空格。

Press enter and you see the output 按Enter键,您将看到输出

This was in Windows 10 Insiders Preview Build 17127.rs4_release and Python 3.6.2 这是在Windows 10 Insiders Preview Build 17127.rs4_release和Python 3.6.2中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM