In PyCharm, you can have multiple carets. Press and hold Alt and then click at different positions to set additional carets in the editor. Alternatively, press Ctrl twice and hold the key, and then press the arrow keys.

You can then press Shift with the left or right arrow keys to select multiple text fragments.

Press &shortcut:EditorEscape; to remove all the additional carets but the most recently added one.