예제 #1
0
“Dump them into the Sea of Bohai!” said everyone.
So Yugong, his sons, and his grandsons started to break up rocks and
remove the earth. They transported the earth and rubble to the Sea
of Bohai.
Now Yugong’s neighbour was a widow who had an only child eight years
old. Evening the young boy offered his help eagerly.
Summer went by and winter came. It took Yugong and his crew a full
year to travel back and forth once.
On the bank of the Yellow River dwelled an old man much respected
for his wisdom. When he saw their back-breaking labour, he ridiculed
Yugong saying,”Aren’t you foolish, my friend? You are very old now,
and with whatever remains of your waning strength, you won’t be able
to remove even a corner of the mountain.”
Yugong uttered a sigh and said,”A biased person like you will never
understand. You can’t even compare with the widow’s little boy!”
“Even if I were dead, there will still be my children, my
grandchildren, my great grandchildren, my great great grandchildren.
They descendants will go on forever. But these mountains will not
grow any taler. We shall level them one day!” he declared with
confidence.
The wise old man was totally silenced.
When the guardian gods of the mountains saw how determined Yugong
and his crew were, they were struck with fear and reported the
incident to the Emperor of Heavens.
Filled with admiration for Yugong, the Emperor of Heavens ordered
two mighty gods to carry the mountains away.
'''

result = stats_word.stats_text(text)

print('统计结果:', result)
예제 #2
0
from mymodule import stats_word
import json

#with open('tang300.json',mode='r+',encoding='utf-8') as t:
   #t1=t.read()
try:
    word = stats_word.stats_text(stats_word.test_get_link(),100)
    stats_word.email(word)

except  ValueError as va:
    print(va)
예제 #3
0
from mymodule import stats_word

file = open(
    '/Users/Justco/selfteaching-python-camp/exercises/1901090003/d09/tang300.json',
    'rb')
text1 = file.read()
text = text1.decode()

print(stats_word.stats_text(text))

file.close()
예제 #4
0
def test_logger():
    try:
        stats_word.stats_text(text)
    except Exception as e:
        logging.exception(e)
#coding=utf-8
from mymodule import stats_word as sw
from pyquery import PyQuery
import requests
import yagmail
import getpass

sender = input('输入发件人邮箱:')
password = getpass.getpass('输入发件人邮箱密码:')
recipients = input('输入收件人邮箱:')
r = requests.get('https://mp.weixin.qq.com/s/pLmuGoc4bZrMNl7MSoWgiA')

document = PyQuery(r.text)
content = document('#js_content').text()
#my_stats = str(sw.stats_text(content, 100))

yag = yagmail.SMTP(user=sender, password=password, host='smtp.163.com')

yag.send(recipients, '19100104 Jacquesxu666', str(sw.stats_text(content, 100)))
예제 #6
0
def test_traceback():
    try:
        stats_word.stats_text(1)
    except Exception as e:
        print('test_traceback =>', e)
        print(traceback.format_exc())
예제 #7
0
def test_traceback():
    try:
        stats_word.stats_text(text)
    except Exception as e:
        print("trace_back==>", e)
        print(traceback.format_exc())
예제 #8
0
Mount Wanwu? Moreover, where will all the earth and rubble go?”
“Dump them into the Sea of Bohai!” said everyone.
So Yugong, his sons, and his grandsons started to break up rocks and
remove the earth. They transported the earth and rubble to the Sea of
Bohai.
Now Yugong’s neighbour was a widow who had an only child eight years
old. Evening the young boy offered his help eagerly.
Summer went by and winter came. It took Yugong and his crew a full
year to travel back and forth once.
On the bank of the Yellow River dwelled an old man much respected for
his wisdom. When he saw their back-breaking labour, he ridiculed
Yugong saying,”Aren’t you foolish, my friend? You are very old now,
and with whatever remains of your waning strength, you won’t be able
to remove even a corner of the mountain.”
Yugong uttered a sigh and said,”A biased person like you will never
understand. You can’t even compare with the widow’s little boy!”
“Even if I were dead, there will still be my children, my
grandchildren, my great grandchildren, my great great grandchildren.
They descendants will go on forever. But these mountains will not
grow any taler. We shall level them one day!” he declared with
confidence.
The wise old man was totally silenced.
When the guardian gods of the mountains saw how determined Yugong and
his crew were, they were struck with fear and reported the incident
to the Emperor of Heavens.
Filled with admiration for Yugong, the Emperor of Heavens ordered two
mighty gods to carry the mountains away.
'''
from mymodule import stats_word
print('合并词频统计结果: ', stats_word.stats_text(text))
예제 #9
0
“Dump them into the Sea of Bohai!” said everyone. 
So Yugong, his sons, and his grandsons started to break up rocks and remove the earth. They transported the earth and rubble to the Sea of Bohai. 
Now Yugong’s neighbour was a widow who had an only child eight years old. Evening the young boy offered his help eagerly. 
Summer went by and winter came. It took Yugong and his crew a full year to travel back and forth once. 
On the bank of the Yellow River dwelled an old man much respected for his wisdom. When he saw their back-breaking labour, he ridiculed Yugong saying,”Aren’t you foolish, my friend? You are very old now, and with whatever remains of your waning strength, you won’t be able to remove even a corner of the mountain.” 
Yugong uttered a sigh and said,”A biased person like you will never understand. You can’t even compare with the widow’s little boy!” 
“Even if I were dead, there will still be my children, my grandchildren, my great grandchildren, my great great grandchildren. They descendants will go on forever. But these mountains will not grow any taler. We shall level them one day!” he declared with confidence. 
The wise old man was totally silenced. 
When the guardian gods of the mountains saw how determined Yugong and his crew were, they were struck with fear and reported the incident to the Emperor of Heavens.  
Filled with admiration for Yugong, the Emperor of Heavens ordered two mighty gods to carry the mountains away. 
") 
print(mymodule.stats_word.stats_text(text)) 

#调用stats_word中的stats_text,且传值text

print(stats_word.stats_text(text))


#第9天,读取文件并排序
ch={}
from mymodule import stats_wordfrom collections import Counterimport json

with open(os. path.join(os.path.dirnam(os.path.abspath(__file__)), 'tang300.json'))as nine:
    read_data=nine.read()
    nine.closed
    read=Counter(stats_word.stats_text(read_data))
    print(read.most_common(100))
try:
    print("全部结果为:",stats_word.stats_text(ch))
except valueError as err
    print(err)
예제 #10
0
def text_traceback():
    try:
        stats_word.stats_text(1)
    except Exception as e:#这里的e是前面MyError类的一个instance,我们可以直接访问他的value,也就是e.value
        print(e)
        print(traceback.format_exc())
예제 #11
0
confidence.
The wise old man was totally silenced.
When the guardian gods of the mountains saw how determined Yugong
and his crew were, they were struck with fear and reported the
incident to the Emperor of Heavens.
Filled with admiration for Yugong, the Emperor of Heavens ordered
two mighty gods to carry the mountains away.
'''


def test_traceback():
    try:
        stats_word.stats_text(1)
    except Exception as e:
        print('test_traceback =>', e)
        print(traceback.format_exc())


def test_logger():
    try:
        stats_word.stats_text(1)
    except Exception as e:
        logger.exception(e)


if __name__ == '__main__':
    test_traceback()
    test_logger()

print('统计结果 ==>', stats_word.stats_text(123))
예제 #12
0
def text_logger():
    try :
        stats_word.stats_text(1)
    except Exception as e:
        logger.exception(e)
예제 #13
0
from mymodule import stats_word

sample_text '''


result = stats_word.stats_text(sammple_text)

print('统计结果 ==>', result)
예제 #14
0
愚公歎息道:「你有這樣的成見,是不會明白的。你比那寡婦的小兒子還不如昵!就算我死 了,還有我的兒子,我的孫子,我的曾孫子,他們一直傳下去。而這二山是不會加大的,總有 一天,我們會把它們剷平。」
智叟聽了,無話可說:
二山的守護神被愚公的堅毅精神嚇倒,便把此事奏知天帝。天帝佩服愚公的精神,就命兩位大 力神揹走二山。
How The Foolish Old Man Moved Mountains
Yugong was a ninety-year-old man who lived at the north of two high mountains, Mount Taixing and Mount Wangwu.
Stretching over a wide expanse of land, the mountains blocked yugong's way making it inconvenient for him and his family to get around.
One day yugong gathered his family together and said,’’Let's do our best to level these two mountains. We shall open a road that leads to Yuzhou. What do you think?"
All but his wife agreed with him.
"You don't have the strength to cut even a small mound,” muttered his wife. "How on earth do you suppose you can level Mount Taixin and Mount Wanwu? Moreover, where will all the earth and rubble go?"
"Dump them into the Sea of Bohaii" said everyone.
So Yugong, his sons, and his grandsons started to break up rocks and remove the earth. They transported the earth and rubble to the Sea of Bohai.
Now Yugong's neighbour was a widow who had an only child eight years old. Evening the young boy offered his help eagerly.
Summer went by and winter came. It took Yugong and his crew a full year to travel back and forth once.
On the bank of the Yellow River dwelled an old man much respected for his wisdom. When he saw their back-breaking labour, he ridiculed Yugong sayingr"Aren't you foolish, my friend? You are very old now, and with whatever remains of your waning strength, you won't be able to remove even a corner of the mountain."
Yugong uttered a sigh and said,〃A biased person like you will never understand. You can't even compare with the widow's little boyl"
"Even if I were dead, there will still be my children, my grandchildren, my great grandchildren, my great great grandchildren. They descendants will go on forever. But these mountains will not grow any taler. We shall level them one day!” he declared with confidence.
The wise old man was totally silenced.
When the guardian gods of the mountains saw how determined Yugong and his crew were, they were struck with fear and reported the incident to the Emperor of Heavens.
Filled with admiration for Yugong, the Emperor of Heavens ordered two mighty gods to carry the mountains away.
'''

with open('tang300.json') as t:
    read_file = t.read()
t.closed

from mymodule import stats_word
try:
    print('合并词频统计结果: ', stats_word.stats_text(read_file, 100))
except ValueError as ve:
    print(ve)
예제 #15
0
of Bohai.
Now Yugong’s neighbour was a widow who had an only child eight years
old. Evening the young boy offered his help eagerly.
Summer went by and winter came. It took Yugong and his crew a full
year to travel back and forth once.
On the bank of the Yellow River dwelled an old man much respected
for his wisdom. When he saw their back-breaking labour, he ridiculed
Yugong saying,”Aren’t you foolish, my friend? You are very old now,
and with whatever remains of your waning strength, you won’t be able
to remove even a corner of the mountain.”
Yugong uttered a sigh and said,”A biased person like you will never
understand. You can’t even compare with the widow’s little boy!”
“Even if I were dead, there will still be my children, my
grandchildren, my great grandchildren, my great great grandchildren.
They descendants will go on forever. But these mountains will not
grow any taler. We shall level them one day!” he declared with
confidence.
The wise old man was totally silenced.
When the guardian gods of the mountains saw how determined Yugong
and his crew were, they were struck with fear and reported the
incident to the Emperor of Heavens.
Filled with admiration for Yugong, the Emperor of Heavens ordered
two mighty gods to carry the mountains away.
'''
text = []

try:
    print('中英文词频统计结果:', stats_word.stats_text(text))
except ValueError:
    print('ValueError:type of argument is not string!')
예제 #16
0
txt = [1, 2.3, 5, 6, 9]
from mymodule import stats_word
try:
    stats_word.stats_text(txt)
except ValueError as err:
    print('具体原因为:{0}'.format(err))  #将错误的信息显示出来