美文网首页
Python 格式化输出 print()

Python 格式化输出 print()

作者: 小螳螂 | 来源:发表于2017-08-27 22:35 被阅读0次

# 格式化输出字符串

print('%.3s'%'zhouzhou')#前3

print('%.*s'% (6,'zhouzhouzhou'))#前6

print('%10.4s'%'zhouzhou')#宽度为10,截取前4位,左边补空格

print('%-10.3s'%'zhouzhou')#宽度为10,截取前3,右边补空格


%r 万能格式符


相关文章

  • Python几种格式化输出

    Python格式化输出 print(userInfo)print(userInfo1)print(userInfo...

  • Python2与Python3中print用法总结

    Python2中的print用法 在Python2 中 print 是一种输出语句 1.格式化输出整数 2.格式化...

  • 入门输入输出篇

    python 的输入和输出 输出 print('hello') 格式化输出: 命令行: >>> 'Hello, %...

  • 【python】格式化输出

    python print格式化输出。 打印字符串print ("His name is %s"%("ofish")...

  • Python %d、%s、%r等用法

    Python print函数用法,print 格式化输出 使用print输出各型的 字符串 整数 浮点数 出度及精...

  • Python目录

    Python基础语法 输出print() 输入input() 数据类型 变量 常量 格式化 list tuple ...

  • Python print 格式化输出

    format 的使用方式如下: 输出为: 另,格式化输出 %s 和 %d 参见:格式化输出 %s 和 %d

  • Python 格式化输出 print()

    # 格式化输出字符串 print('%.3s'%'zhouzhou')#前3print('%.*s'% (6,'z...

  • #python

    #Python print()函数 #输出数字,运算结果 print(1) print(1+1) #print输出...

  • #python 0

    #Python print()函数 #输出数字,运算结果 print(1) print(1+1) #print输出...

网友评论

      本文标题:Python 格式化输出 print()

      本文链接:https://www.haomeiwen.com/subject/gagidxtx.html