learn python(1) print语法

来源:互联网 发布:win7如何优化系统 编辑:程序博客网 时间:2024/06/16 11:02

1.Preface

The Zen of Python, by Tim Peters


Beautiful is better than ugly.

Explicit is better than implicit.

Simple is better than complex.

Complex is better than complicated.

Flat is better than nested.

Sparse is better than dense.

Readability counts.

Special cases aren't special enough to break the rules.

Although practicality beats purity.

Errors should never pass silently.

Unless explicitly silenced.

In the face of ambiguity, refuse the temptation to guess.

There should be one-- and preferably only one --obvious way to do it.

Although that way may not be obvious at first unless you're Dutch.

Now is better than never.

Although never is often better than *right* now.

If the implementation is hard to explain, it's a bad idea.

If the implementation is easy to explain, it may be a good idea.

Namespaces are one honking great idea -- let's do more of those!

2.print语法

几个需要注意的点:

①print语句里语句太长,可利用转义符号“\”来进行转行处理。


②对于Python2,若print语句里既有字符串又有数字,利用“%d”,"%f"等符号,后面跟上%(代表的变量),注意%前没有逗号,如上例。
③若print语句后并不想换行,其语句格式为在print整个语句后加逗号。

0 0
原创粉丝点击