Python编程:如何使用字符串的center()方法
1、首先在PyCharm软件中,打开一个Python项目。

3、在python文件编辑区中,输入:“txt = "hello"”。

5、再次输入:“print(x)”进行打印。

7、在运行结果窗口中,已经使用Python字符串的center()方法打印单词“hello”,占用 20 个字符,并使“hello”居中。

1、首先在PyCharm软件中,打开一个Python项目。
3、在python文件编辑区中,输入:“txt = "hello"”。
5、再次输入:“print(x)”进行打印。
7、在运行结果窗口中,已经使用Python字符串的center()方法打印单词“hello”,占用 20 个字符,并使“hello”居中。