这个问题可以通过Python的切片操作来实现。首先,我们需要定义一个字符串str,然后使用切片操作将其内容颠倒过来。具体代码如下: ```python str = "hello, world!" str = str[::-1] print(str) ``` 这段代码首先定义了一个字符串"hello, world!",然后通过切片操作将其内容颠倒过来。切片操作中的"[::-1]"表示从后向前遍历字符串,因此输出结果为"!dlrow ,olleh"。