无涯教程-Python - str(dict)函数

79 阅读1分钟

Python dict str()生成字典的可打印字符串表示。

str(dict) - 语法

str(dict)
  • dict  -  这是字典。

str(dict) - 返回值

此方法返回字符串表示形式。

str(dict) - 示例

以下示例显示了str()方法的用法。

#!/usr/bin/python

dict={Name: Learnfk, Age: 7}; print "Equivalent String : %s" % str (dict)

当无涯教程运行上面的程序时,它产生以下输出-

Equivalent String : {Age: 7, Name: Learnfk}

参考链接

www.learnfk.com/python/dict…