简体   繁体   English

如何在 python 中打印不带格式的字符串?

[英]How to print the string without formatting in python?

Is there any possibility or way to print the string with out passing any arguments or without formatting in python?是否有任何可能性或方法可以在不传递任何 arguments 或不在 python 中进行格式化的情况下打印字符串?

To @Blender.给@Blender。

I have done an simple script using mysqlDB module to interact with the mysql server.我已经使用 mysqlDB 模块完成了一个简单的脚本来与 mysql 服务器进行交互。 Using that script i can execute the mysql query to get the output of it.使用该脚本,我可以执行 mysql 查询以获取它的 output。

For an example, if i pass the input as " show master logs " into the script i am getting the error as例如,如果我将输入作为“show master logs”传递到脚本中,我得到的错误是

TypeError: not enough arguments for format string.类型错误:arguments 格式字符串不足。

Here i cannot pass the enough agru.net to print the output. Because, if i pass the enough argument to print the output, the i cannot print the output of query which has more argument.在这里,我无法传递足够的 agru.net 来打印 output。因为,如果我传递了足够的参数来打印 output,我就无法打印具有更多参数的查询的 output。 So, i want to print the output without any argument.所以,我想不带任何参数地打印 output。

It is possible or any alternative solution is there, suggest me.建议我,这是可能的,或者有任何替代解决方案。 I am learner in python我是 python 的学习者

Yes, just print it:是的,只需打印它:

>>> print "hello %s"
hello %s

No formatting occurs, as opposed to:没有格式化发生,而不是:

>>> print "hello %s" % "there"
hello there

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM