你好,你上傳的魚C工作室_彙編解壓密碼是什麼啊 ?
- 2022-03-26
一般沒有密碼,如果有的話試試fishc。com或者fishc
1,使用getopt。getopt()最佳化當前的功能函式:
[html]
#!/usr/bin/python
# -*- coding: utf-8 -*-
#coding=utf-8
import os,sys
import getopt
print sys。argv
cdrow=‘/home/zhouqian/test’
def cdwalker(cdrow,cdfile):
result=[]
for root,dirs,files in os。walk(cdrow):
result。append(“%s %s %s” %(root,dirs,files))
print root
open(cdfile,‘w’)。write(‘\n’。join(result))
def usage():
print ‘’‘pycdc 使用方式:
python cdays-3-exercise-1。py -d cdc -k 中國火
#檢索cdc中有沒有中國火字樣的目錄,
’‘’
try:
opts,args=getopt。getopt(sys。argv[1:],‘hd:e:k:’)
except getopt。getopterror:
usage()
sys。exit()
if len(opts)==0:
usage()
sys。exit()
c_path=‘’
name=‘’
for opt,arg in opts:
if opt in(‘-h’,‘——help’):
usage()
sys。exit()
elif opt==‘-e’:
if os。path。exists(arg):#判斷目標路徑是否存在
# cdwalker(cdrow,arg)
print “記錄光碟的位置是 %s” %arg
else:
print “不存在這樣的目錄”
elif opt==‘-d’:
c_path=arg
print c_path
cdwalker(cdrow,c_path)
elif opt==‘-k’:
if not c_path:
usage()
sys。exit()
else:
name=arg
for root,dirs,files in os。walk(c_path):
if root==‘%s’ %name:
print ‘您要找的檔案在%s’ %dirs
這是第一個題,大概做了2個小時吧,各種糾結啊,後面兩個正在做。中間遇到的問題總結:
函式的利用,os。path。walk,python字符集,getopt模組的使用學習,os。path。exists()的利用,列表的對應關係等等
習題2 :關鍵詞——-》序列號問題:
[html]
#!/usr/bin/python
#coding=utf-8
import sys
def collect(file):
result={}
for line in file。readlines():
left,right=line。split()
if result。has_key(right):
result[right]。append(left)
else:
result[right]=[left]
return result
if __name__==“__main__”:
print sys。argv
if len(sys。argv)==1:
print ‘usage:\tpython value_keys。py test。txt’
else:
result=collect(open(sys。argv[1],‘r’))
for (right,left) in result。items():
print “%d %s => %s” %(len(left),right,left)
結果顯示:
[html]
root@zhou:/home/zhouqian/python# py value_keys。py test。txt
ssss
2 key3 => [‘6’, ‘33’]
3 key2 => [‘1’, ‘2’, ‘45’]
3 key1 => [‘4’, ‘5’, ‘13’]
遇到的問題總結:
split的用法:line。split()就是分開出左右兩邊的值,在預設的情況下是以一個空格或者多個空格為分割符的,
has_key()的用法:是檢視字典資料型別中有沒有這麼一個關鍵字。上面可知result={}是初始化了一個字典的資料型別。
字典的一些用法:怎麼定義,怎麼賦值:result[right]=[left]或者result[right]=left,遍歷字典中所用
項,result。items(),遍歷字典的key值:result。keys(),遍歷字典的value值:result。values()
[html]
>>> dict={‘chen’:25,‘zhou’:24,‘xiao’:35}
>>> dict。values()
[25, 35, 24]
>>> dict。keys()
[‘chen’, ‘xiao’, ‘zhou’]
>>> dict。items()
[(‘chen’, 25), (‘xiao’, 35), (‘zhou’, 24)]