python如何用百分号格式化

时间:2026-02-15 20:22:03

1、1:打开pycharm,进入到pycharm主界面

python如何用百分号格式化

2、2:新建脚本命令

    点击左键--点击new---点击python file

python如何用百分号格式化

3、3:输入代码,代码如下 %s 就是百分号格式化,我们也可以把多个位置都百分号格式化

s = "https://jingyan.baidu.com/article/%s.html" % a  

python如何用百分号格式化

4、4:复制第三步代码,把jingyan更改为百分号格式化,这样代码就如下

s2 = "https://%s.baidu.com/article/%s.html" % ("jingyan",10)

python如何用百分号格式化

5、5:输入打印输出命令print,然后点击运行,信息框就会返回我们想要的值

python如何用百分号格式化

© 2026 一点知道
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com