Python
何亚前
这个作者很懒,什么都没留下…
展开
-
[Python]character-formatting
字符串格式化操作符(%)只适用于字符串类型,非常类似于C 语言里面的printf()函数的字符串格式化,甚至所用的符号都一样,都用百分号(%),并且支持所有printf()式的格式化操作。语法如下: format_string % string_to_convert format_string为格式标记字符串,形式为“%cdoe”; string_to_convert 为要格式化的字符串转载 2017-12-24 16:21:40 · 827 阅读 · 0 评论 -
[Python] example-seven-string concatenation
字符串连接的方法:1.+号直接连接w = "This is the left side of..."e = "a string with a right side."print w + e输出结果:2.用,号连接,但是两字符串之间有空格end1 = "C"end2 = "h"end3 = "e"end4 = "e"end5 = "s"原创 2017-12-24 17:04:46 · 380 阅读 · 0 评论 -
[Python] example-nine 转义序列
转义序列\\Backslash()反斜杠\'Single quote(‘)单引号\"Double quote(“)双引号\aASCII Bell(BEL)响铃符\bASCII Backspace(BS)退格符\fASCII Formfeed(FF)进纸符\n原创 2017-12-26 17:12:19 · 179 阅读 · 0 评论 -
[Python] example-ten 三引号打印多行
三引号打印多行print """There's something going on here.With the three double-quotes.We'll be able to type as much as we like.Even 4 lines if we want, or 5 ,or 6."""输出结果:原创 2017-12-26 18:26:11 · 281 阅读 · 0 评论 -
[Python] example-one File"<stdin>",line 1错误
出现File“”,line1错误原创 2017-12-22 21:06:57 · 2794 阅读 · 0 评论 -
[Python] example-thirteen need more than 1 value to unpack
Code:from sys import argvscript, first , second, third = argvprint "The script is called:", scriptprint "Your first variable is:", firstprint "Your second variable is:", secondprint "Your third...原创 2017-12-27 16:43:22 · 264 阅读 · 2 评论 -
[Python] example-fifteen IndentationError: unexpected indent
都知道python是对格式要求很严格的,写了一些python但是也没发现他严格在哪里,今天遇到了IndentationError: unexpected indent错误我才知道他是多么的严格。 以后遇到了IndentationError: unexpected indent你就要知道python编译器是在告诉你“Hi,老兄,你的文件里格式不对了,可能是tab和空格没对齐的问题,你需要检查下t原创 2017-12-27 21:07:29 · 170 阅读 · 0 评论 -
[Python] example-sixteen file command
简单接触到的几个关于文件的命令truncate(n)截断文件命令 从文件的首行首字符开始截断,截断文件为n个字符;无n表示从当前位置起截断,截断之后n后面的所有字符被删除。原创 2017-12-28 21:27:12 · 129 阅读 · 0 评论 -
[Python] example-thirty 判断结构之elif
判断结构语法形式:1、if 布尔表达式: 语句块2、if 布尔表达式: 语句块 else: 语句块3、if 布尔表达式: 语句块 elif 布尔表达式: 语句块 elif 布尔表达式: 语句块 ........ else: 语句块我想重点介绍elif,这个属于多路分支...原创 2018-03-20 17:16:47 · 215 阅读 · 0 评论