面对100多套ORACLE数据库,领导想问数据库链都有多少啊,给我查出来。我:好的conn.txt 内容是 scott/tiger@orcl1scott/tom@zhcx2...(以下是一百个连接信息,略)import cx_Oracle with open("conn.txt", "r") as f: for line in f.readlines(): ...【阅读全文】
[root@localhost /]# [root@localhost /]# cat zlg.py #!/bin/pythonfrom random import randintimport timemylist=[1,2,3,4]mylist.reverse()for x in mylist: print xmytuple=(1,2,3,4)for y in range(len(mytuple)-1,-1,-1): print mytuple[y]mystr='hello you are a b...【阅读全文】
[root@localhost /]# [root@localhost /]# cat ./for.py #!/bin/pythonfrom random import randintfrom itertools import chaina=[randint(10,100) for _ in range(20)]b=[randint(10,100) for _ in range(20)]c=[randint(10,100) for _ in range(20)]for n,m,v in zip(a,b,c): print n+m+vcou...【阅读全文】
[root@localhost /]# [root@localhost /]# cat strduiqi.py #!/bin/pythonimport os, statli=os.listdir('/software/script/shell')st=[n for n in li if n.endswith(('.sh','.py'))]for nm in st: os.chmod(nm,os.stat(nm).st_mode | stat.S_IXGRP)[root@localhost /]# [root@localhost /]# ...【阅读全文】
使用python中的字典来模拟其他语言中的case,switch 语句。使用函数作为字典的value. 看代码很直观。该代码出自The Python Master一书.点击(此处)折叠或打开def labyrinth(position, alive): print('You are in a maze of twisty passages, all alike...【阅读全文】