#第0004
import
rere_word=re.compile(
r'[a-za-z]+'
)def
count_words
(object):
count =
0for
line
in object:
nums=re_word.findall(line)
count+=
len(nums)
return
count
if __name__==
"__main__"
: filename=
"count_words.txt"
with
open
(filename)
as outfile:
(count_words(outfile))
問題:1.如果存在字元為ex2,該語句會識別ex,但實際中我需要放棄識別這個字串,我應該怎麼辦呢?(加入程式做預處理,然後再進行?)
每天一python 題 0002
第 0002 題 將 0001 題生成的 200 個啟用碼 或者優惠券 儲存到 mysql 關係型資料庫中。涉及的內容 python操縱mysql資料庫,推薦慕課網的相關課程 作業 如下 coding utf 8 import pymysql import random,string conn py...
Python每天一題 0000
coding utf 8 from pil import image im image.open c 1.png print im.show 使用image模組,i是大寫的,要寫from pil 不能直接寫import 使用dir檢視im有的屬性和方法。先試了size im.size 返回乙個元組 ...
Python每天一題 0001
今天比較有空就在寫乙個 這個就比較簡單了 就是生成啟用碼200個 我寫的是數字和大寫字母都有的那種 像這種 anoqeo8m taeccdki fhni80h1 y9w1wa4b 用的random的choice在列表中隨機出乙個,然後我讓他字元累加在一起8個 就是可以有256種。coding utf...