Pycharm 简明教程
Pycharm - Improving and Writing Code
PyCharm 包含各种编写代码的标准,其中适用于 Python 的缩进有效。这使得在 PyCharm 编辑器中提高代码标准和编写完整代码变得很有意思。
PyCharm includes various standards for writing code with proper indentations valid for Python. This makes it interesting to improve the code standards and writing the complete code in PyCharm editor.
Improving Code Completion
PyCharm 中的代码自动完成非常独特。您可以使用许多其他功能进一步增强它。请注意,编辑器提供了代码块的开始和结束。考虑一个名为 demo.py 的文件,其中包含以下代码 −
Code completion in PyCharm is really unique. You can enhance it further using many other features. Note that the editor provides start and end of the code block. Consider a file named demo.py with the following code −
message = 'GIEWIVrGMTLIVrHIQS' #encrypted message
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for key in range(len(LETTERS)):
translated = ''
for symbol in message:
if symbol in LETTERS:
num = LETTERS.find(symbol)
num = num - key
if num < 0:
num = num + len(LETTERS)
translated = translated + LETTERS[num]
else:
translated = translated + symbol
print('Hacking key #%s: %s' % (key, translated))
代码使用以下构造完成 −
The code is completed using the following construct −

当此弹出窗口在屏幕上时,如果您按 Ctrl + 空格键,则可以看到更多代码自动完成选项 −
If you press Ctrl + spacebar while this popup is on the screen, you can see more code completion options −

Intention Actions
PyCharm 包含特定意图的操作,其快捷键为 Alt+Enter 。工作意图的最重要的示例是在字符串中使用语言注入。
PyCharm includes intent specific actions and the shortcut key for the same is Alt+Enter. The most important example of intentions at work is using language injection in strings.
下面给出的屏幕截图显示了意图操作的工作原理 −
The screenshot given below shows the working of intention actions −

请注意,我们可以在 PyCharm 编辑器中插入许多不同语言的意图操作。
Note that we can insert many different languages of intention actions in PyCharm Editor.