字符串认知与应用 认知1: 字符串的概念 认知2: acii unicode utf8到底是啥 Python默认的文件编码是ascii 1. len 之注意事项 ( decode()需要测试 ) >>> len("分析") 4 >>> len(u"分析") 2 2. 转义字符串 print('adb ...
分类:
编程语言 时间:
2016-05-20 00:34:48
阅读次数:
248
定义字典 dic = {'a':"hello",'b':"how",'c':"you"} 方法一: for key in dic: print key,dic[key] print key + str(dic[key]) 结果: a hello ahello c you cyou b how bho ...
分类:
编程语言 时间:
2016-05-19 20:51:28
阅读次数:
163
列表作为有序数据类型。大部分操作和字符串类似。别如获取列表的元素;切片操作等。1:索引(下标)2:增、删、改、查3:常用函数4:列表解析一:索引:通字符串一样,从左到右。索引从0开始到len(list)-1结束。从右到左,-len(list)到-1。a=[1,2,3,4]
print(a[0])
print(a[-1]..
分类:
编程语言 时间:
2016-05-19 19:35:59
阅读次数:
266
应用场景:有时候数据输出的时候,需要序列下标,以方面供他人进行选择。例子:dict1={
‘mac‘:7000,
‘coffe‘:30,
‘banana‘:5
}
print(‘whatdoyouwanttobuy?:‘)
forindex,iinenumerate(dict1.keys()):
print(index,i)enumerate()函数需要2个参数,一个输出文件的序列。一个输出..
分类:
编程语言 时间:
2016-05-19 19:31:48
阅读次数:
138
#!/bin/bash
#monitortomcat_log
LOG_DIR=/root/catalina.out
IP=`ifconfig|grep"inetaddr"|grepBcast|awk-F‘[:]+‘‘{print$4}‘`
tail-Fn0$LOG_DIR|whilereadline;do
echo$line|grep-i-f/root/errorword.txt>/dev/null
if[$?-eq0];then
echo-e"IP:$IP\nDatetime:$(dat..
分类:
其他好文 时间:
2016-05-19 19:31:44
阅读次数:
153
linux中的文件查找远远比windows中文件查找要强大的多,而且是更加的迅速,以下是我通过阅读网上的文档整理了一部分linux中文件查找find的命令,及其命令含义解释。一.命令格式:findpathname-options[-print-exec-ok...]二.命令功能:用于在文件树种查找文件,并作出相应的处..
分类:
其他好文 时间:
2016-05-19 19:29:47
阅读次数:
292
class S(object): def Test(self): print("TEST") @classmethod def Test02(cls): print("class") @staticmethod def Test03(): print("Test03")class Test2(S): ...
分类:
编程语言 时间:
2016-05-19 18:57:05
阅读次数:
192
1、 cd /home 进入 '/ home' 目录' (change directory) cd .. 返回上一级目录 cd ../.. 返回上两级目录 cd 进入个人的主目录 cd ~user1 进入个人的主目录 cd - 返回上次所在的目录 pwd 显示工作路径 (print work dir ...
分类:
系统相关 时间:
2016-05-19 13:06:35
阅读次数:
184
总结: 内部函数,不修改全局变量可以访问全局变量 内部函数,修改同名全局变量,则python会认为它是一个局部变量 在内部函数修改同名全局变量之前调用变量名称(如print sum),则引发Unbound-LocalError 在程序中设置的sum属于全局变量,而在函数中没有sum的定义,根据pyt ...
分类:
其他好文 时间:
2016-05-19 10:37:52
阅读次数:
121
1.hasattr和getattr#!/usr/bin/envpython
#-*-coding:utf-8–*-
importsys
classWebServer(object):
def__init__(self,host,port):
self.ip=host
self.port=port
defstart(self):
print("startserver..")
defstop(self):
print("stopserver..")
defrestart(self):
self.st..
分类:
编程语言 时间:
2016-05-19 06:48:48
阅读次数:
206