diff --git a/gini5/0000/ARLRDBD.TTF b/gini5/0000/ARLRDBD.TTF new file mode 100644 index 00000000..20b92a27 Binary files /dev/null and b/gini5/0000/ARLRDBD.TTF differ diff --git a/gini5/0000/add_number.py b/gini5/0000/add_number.py new file mode 100644 index 00000000..51bcb5b3 --- /dev/null +++ b/gini5/0000/add_number.py @@ -0,0 +1,12 @@ +from PIL import Image, ImageDraw, ImageFont + +def add_number(img): + draw = ImageDraw.Draw(img) + fnt = ImageFont.truetype('ARLRDBD.TTF', 30) + width, height = img.size + draw.text((width*0.8,0),"12",font=fnt,fill="#ff0000") + img.save("newImage.jpg") + +if __name__ == "__main__": + im = Image.open("image.jpg") + add_number(im) \ No newline at end of file diff --git a/gini5/0001/random_string.py b/gini5/0001/random_string.py new file mode 100644 index 00000000..f0a5f989 --- /dev/null +++ b/gini5/0001/random_string.py @@ -0,0 +1,16 @@ +import random, string + +dic = {} + +def generate_string(size=8): + seed = string.ascii_letters+string.digits + res = ''.join(random.sample(seed,size)) + return res + +for i in range(200): + new = generate_string() + while new in dic.values(): + new = generate_string() + dic[i] = new + +print(dic) diff --git a/gini5/0002/toMySql.py b/gini5/0002/toMySql.py new file mode 100644 index 00000000..7813b47a --- /dev/null +++ b/gini5/0002/toMySql.py @@ -0,0 +1,31 @@ +import MySQLdb, random, string +db = MySQLdb.connect(host="localhost", port = 3306, user="root",passwd="test123",db="mysql") +cursor = db.cursor() + + +dic = {} + +def generate_string(size=8): + seed = string.ascii_letters+string.digits + res = ''.join(random.sample(seed,size)) + return res + +for i in range(200): + new = generate_string() + while new in dic.values(): + new = generate_string() + dic[i] = new + query = "INSERT INTO ACTIVATION_CODE VALUES(%d,%r)"%(i,new) + cursor.execute(query) + +try: + db.commit() +except: + db.rollback() + +# select # +cursor.execute('SELECT * FROM ACTIVATION_CODE') +data = cursor.fetchall() +print(data) +cursor.close() +db.close() \ No newline at end of file diff --git a/gini5/0004/countWords.py b/gini5/0004/countWords.py new file mode 100644 index 00000000..90a78e4c --- /dev/null +++ b/gini5/0004/countWords.py @@ -0,0 +1,14 @@ +cnt = 0 +dic = {} +with open('test.txt','r') as f: + data = f.read().split(' ') + +for word in data: + word = word.lower() + if word not in dic: + dic[word] = 1 + else: + dic[word] += 1 + +for item in sorted(dic.items(),key=lambda x: x[1],reverse=True): + print(item) \ No newline at end of file diff --git a/gini5/0004/test.txt b/gini5/0004/test.txt new file mode 100644 index 00000000..f89ed02a --- /dev/null +++ b/gini5/0004/test.txt @@ -0,0 +1,2 @@ +Data and information are often used interchangeably; however, the extent to which a set of data is informative to someone depends on the extent to which it is unexpected by that person. The amount of information content in a data stream may be characterized by its Shannon entropy. +While the concept of data is commonly associated with scientific research, data is collected by a huge range of organizations and institutions, including businesses (e.g., sales data, revenue, profits, stock price), governments (e.g., crime rates, unemployment rates, literacy rates) and non-governmental organizations (e.g., censuses of the number of homeless people by non-profit organizations). \ No newline at end of file diff --git a/gini5/0006/countWord.py b/gini5/0006/countWord.py new file mode 100644 index 00000000..10eeb17f --- /dev/null +++ b/gini5/0006/countWord.py @@ -0,0 +1,9 @@ +# -*- coding:utf-8 -*- +import os, collections + +'''practice5中遍历目录中文件的方法,读取所有文件''' +diarydir = r'./diary/' +file_list = os.walk(diarydir) +s = set() +map = {} + diff --git a/gini5/0006/diary/diary1.txt b/gini5/0006/diary/diary1.txt new file mode 100644 index 00000000..41fc2673 --- /dev/null +++ b/gini5/0006/diary/diary1.txt @@ -0,0 +1,9 @@ +You are watching a film in which two men are having a fight. They hit one another hard. At the start they only fight with their fists. But soon they begin hitting one another over the heads with chairs. And so it goes on until one of the men crashes through a window and falls thirty feet to the ground below. He is deadOf course he isn't really dead. With any luck he isn't even hurt. Why? Because the men who fall out of high windows or jump from fast moving trains, who crash cars of even catch fire, are professionals. They do this for a living. These men are called stuntmen. That is to say, they perform tricks.There are two sides to their work. They actually do most of the things you see on the screen. For example, they fall from a high building. However, they do not fall on to hard ground but on to empty cardboard boxes covered with a mattress . Again, when they hit one another with chairs, the chairs are made of soft wood and when they crash through windows, the glass is made of sugar!But although their work depends on trick of this sort, it also requires a high degree of skill and training. Often a stuntman' s success depends on careful timing. For example, when he is "blown up" in a battle scene, he has to jump out of the way of the explosion just at the right moment. + +Naturally stuntmen are well paid for their work, but they lead dangerous lives. They often get seriously injured, and sometimes killed. A Norwegian stuntman, for example, skied over the edge of a cliff a thousand feet high. His parachute failed to open, and he was killed. In spite of all the risks, this is no longer a profession for men only. Men no longer dress up as women when actresses have to perform some dangerous action. For nowadays there are stuntgirls tool. +In some ways, the United States has made some progress. Fires no longer destroy 18,000 buildings as they did in the Great Chicago Fire of 1871, or kill half a town of 2,400 people, as they did the same night in Peshtigo, Wisconsin. Other than the Beverly Hill Supper Club fire in Kentucky in 1977, it has been four decades since more than 100 Americans died in a fire. + +But even with such successes, the United States still has one of the worst fire death rates in the world. Safety experts say the problem is neither money nor technology, but the indifference of a country that just will not take fires seriously enough. + +American fire departments are some of the world's fastest and best-equipped. They have to be. The United States has twice Japan's population, and 40 times as many fires. It spends far less on preventing fires than on fighting them. And American fire -safety lessons are aimed almost entirely at children, who die in large numbers in fires but who, against popular beliefs, start very few of them. + diff --git a/gini5/0006/diary/diary2.txt b/gini5/0006/diary/diary2.txt new file mode 100644 index 00000000..3d00bd58 --- /dev/null +++ b/gini5/0006/diary/diary2.txt @@ -0,0 +1,6 @@ +Experts say the error is an opinion that fires are not really anyone's fault. That is not so in other countries, where both public education and the law treat fires as either a personal failing or a crime. Japan has many wood houses; of the 48 fires in world history that burned more than 10,000 buildings, Japan has had 27. Punishment for causing a big fire can be as severe as life imprisonment. + +In the United States, most education dollars are spent in elementary schools. But, the lessons are aimed at too limited a number of people; just 9 percent of all fire deaths are caused by children playing with matches. + +The United States continues to depend more on technology than laws or social pressure. There are smoke detectors in 85 percent of all homes. Some local building laws now require home sprinklers . New heaters and irons shut themselves off if they are tipped. +Today is the date of that afternoon in April a year ago when I first saw the strange and attractive doll in the window of Abe Sheftel's toy shop on Third Avenue near Fifteenth Street, just around the corner from my office, where the plate on the door reads. Dr Samuel Amory. I remember just how it was that day: the first sign of spring floated across the East River, mixing with the soft - coal smoke from the factories and the street smells of the poor neighbourhood. As I turned the corner on my way to work and came to Sheftel's, I was made once more known of the poor collection of toys in the dusty window, and I remembered the coming birthday of a small niece of mine in Cleveland, to whom I was in the habit of sending small gifts. Therefore, I stopped and examined the window to see if there might be anything suitable, and looked at the collection of unattractive objects--a red toy fire engine, some lead soldiers, cheap baseballs, bottles of ink, pens, yellowed envelopes, and advertisements for soft - drinks. And thus it was that my eyes finally came to rest upon the doll stored away in one corner, a doll with the strangest, most charming expression on her face. I could not wholly make her out, due to the shadows and the film of dust through which I was looking, but I was sure that a deep impression had been made upon me as though I had run into a person, as one does sometimes with a stranger, with whose personality one is deeply impressed. \ No newline at end of file diff --git a/gini5/0006/diary/diary3.txt b/gini5/0006/diary/diary3.txt new file mode 100644 index 00000000..39ca7e6f --- /dev/null +++ b/gini5/0006/diary/diary3.txt @@ -0,0 +1 @@ +the and to to to. to' \ No newline at end of file