├── .gitignore
├── FusionFace
└── fusionFace.py
├── README.md
├── anjia
├── __init__.py
├── actor.py
├── anjia.png
├── bg.jpg
├── cloud.py
├── comment.csv
├── comment.py
├── data.csv
├── spd.py
└── star.py
├── bdindex
└── bdindexneed.py
├── cherry_tree
└── cherry_tree.py
├── day-001
└── hello.py
├── day-002
├── identifier.py
├── indent.py
└── print.py
├── day-003
├── Dictionary.py
├── List.py
├── Sets.py
├── String.py
├── Tuple.py
├── number.py
└── variable.py
├── day-004
├── break.py
├── continue.py
├── for.py
├── if.py
├── pass.py
├── range.py
└── while.py
├── day-005
└── def.py
├── day-006
├── cal
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-37.pyc
│ │ └── calculator.cpython-37.pyc
│ └── calculator.py
├── do.py
└── hello.py
├── day-007
├── __init__.py
└── sequence.py
├── day-008
├── __init__.py
└── list.py
├── day-009
├── __init__.py
└── tupple.py
├── day-010
├── __init__.py
└── class.py
├── day-011
├── __init__.py
├── dict_fromkeys.py
├── dictionary-in.py
├── dictionary.py
├── dictionary_copy.py
├── dictionary_del.py
├── dictionary_get.py
├── dictionary_items.py
├── dictionary_keys.py
├── dictionary_pop.py
├── dictionary_popitem.py
├── dictionary_setdefault.py
├── dictionary_update.py
└── dictionary_values.py
├── day-012
├── __init__.py
├── find_max_of_number.py
└── print_id.py
├── day-013
├── __init__.py
└── input_output.py
├── day-014
└── hello.py
├── day-015
├── __init__.py
├── set.py
├── set_difference.py
├── set_difference_update.py
├── set_intersection.py
├── set_intersection_update.py
├── set_isdisjoint.py
├── set_issubset.py
├── set_issuperset.py
├── set_symmetric_difference.py
├── set_union.py
└── symmetric_difference_update.py
├── day-016
└── python-error-and-exception.py
├── day-017
├── __init__.py
├── function_param.py
├── template.py
└── templates
│ ├── hello.html
│ ├── template.html
│ └── 新建文本文档.txt
├── day-018
├── __init__.py
├── filter.py
├── higher_func.py
├── map.py
├── reduce.py
└── sorted.py
├── day-019
├── __init__.py
└── createIterator.py
├── day-020
├── __init__.py
└── decorator_hub.py
├── day-021
├── .DS_Store
├── python_web_filter.py
└── templates
│ ├── base.html
│ ├── filter.html
│ ├── for.html
│ ├── hello2.html
│ ├── hello3.html
│ ├── index.html
│ ├── json.html
│ ├── marco.html
│ ├── myfilter.html
│ └── mymarco.html
├── day-022
├── python_namespace.py
└── python_scope.py
├── day-024
└── standard_lib02.py
├── day-025
└── datetime&time.py
├── day-026
├── __init__.py
└── os_example.py
├── day-027
├── __init__.py
├── folder1
│ ├── fdst.txt
│ └── fsrc.txt
├── shutil_demo.py
└── tmp
│ └── fsrc.txt
├── day-028
├── __init__.py
├── count_log.txt
├── hello_python.txt
├── sys_argv_example.py
├── sys_path_example.py
├── sys_stdin_example.py
└── sys_stdout_example.py
├── day-029
├── Queue.empty2.2.py
├── Queue.full2.3.py
├── Queue.get.py
├── Queue.get_nowait.py
├── Queue.put.py
├── Queue.put_nowait.py
├── Queue.qsize.py
├── join-task_done1.py
├── join-task_done2.py
├── queue.Empty.py
├── queue.Full.py
├── queue.LifoQueue.py
├── queue.PriorityQueue.py
├── queue.Queue.py
└── queue.SimpleQueue.py
├── day-030
├── ChainMap_demo.py
├── Counter_demo.py
├── OrderedDict_demo.py
├── defaultdict_demo.py
├── deque_demo.py
└── namedtuple_demo.py
├── day-031
└── random.py
├── day-032
├── __init__.py
├── advance-operationLog
│ ├── __init__.py
│ └── operation_log.py
├── configLogging
│ ├── __init__.py
│ ├── config_logging.py
│ ├── logging.conf
│ └── recorder.py
├── message2file.py
├── message_format.py
├── multi-module
│ ├── __init__.py
│ ├── __pycache__
│ │ └── mylib.cpython-36.pyc
│ ├── myapp.log
│ ├── myapp.py
│ └── mylib.py
├── python_logging.py
└── show_logtime.py
├── day-033
├── __init__.py
├── enum_access.py
├── enum_auto.py
├── enum_compare.py
├── enum_create.py
├── enum_extend.py
├── enum_function.py
├── enum_iterate.py
├── enum_order.py
└── enum_unique.py
├── day-034
├── json-dump&dumps.py
├── json-load&loads.py
└── pickle.py
├── day-035
├── 1.py
├── 2.py
├── 3.py
├── 4.py
├── 5.py
├── 6.py
└── 7.py
├── day-036
├── __init__.py
└── calendar_demo.py
├── day-037
├── __init__.py
└── math_demo.py
├── day-038
├── __init__.py
└── decimal_demo.py
├── day-039
├── .DS_Store
├── itertools-chain-demo.py
├── itertools-combinations-demo.py
├── itertools-combinations_with_replacement-demo.py
├── itertools-compress-demo.py
├── itertools-count-demo.py
├── itertools-cycle-demo.py
├── itertools-dropwhile-demo.py
├── itertools-filterfalse-demo.py
├── itertools-groupby-demo.py
├── itertools-islice-demo.py
├── itertools-permutations-demo.py
├── itertools-product-demo.py
├── itertools-repeat-demo.py
├── itertools-starmap-demo.py
└── itertools-takewhile-demo.py
├── day-040
├── .DS_Store
└── statistics-demo.py
├── day-041
└── operatior.py
├── day-042
├── paramiko_cmd.py
├── paramiko_file.py
├── paramiko_pty.py
└── paramiko_searchFile.py
├── day-043
└── filecmp&difflib.py
├── day-044
├── flaskbootstrap.py
├── static
│ ├── css
│ │ ├── bootstrap.min.css
│ │ └── style.css
│ └── js
│ │ ├── bootstrap.min.js
│ │ ├── jquery.min.js
│ │ └── popper.min.js
└── templates
│ ├── base.html
│ ├── index.html
│ ├── post.html
│ └── user.html
├── day-045
├── app.py
└── templates
│ ├── bootstrap.html
│ ├── submit.html
│ └── upload.html
├── day-046
├── .DS_Store
├── app.py
└── templates
│ ├── createprofile.html
│ └── profile.html
├── day-047
└── app.py
├── day-048
├── __init__.py
├── compute_multi_process.py
├── compute_multi_thread.py
├── compute_single_thread.py
├── io_multi_process.py
├── io_multi_thread.py
├── io_single_thread.py
└── tmp.txt
├── day-049
├── __init__.py
├── daemon.py
├── local.py
├── new.py
└── timer.py
├── day-050
├── producer_consumer_final_version.py
└── producer_consumer_simple_version.py
├── day-051
├── queue_common_function_demo.py
├── queue_put_get_demo.py
└── queue_three_queue_compare_demo.py
├── day-052
├── __pycache__
│ └── multiprocessing.cpython-37.pyc
├── multiprocessing-lock.py
├── multiprocessing-pipe.py
├── multiprocessing-queue.py
├── multiprocessingDemo.py
├── queue_common_function_demo.py
├── queue_put_get_demo.py
└── queue_three_queue_compare_demo.py
├── day-053
├── ThreadPoolExecutor-demo.py
└── threadpool-demo.py
├── day-054
├── printLetterAndNumber.py
└── trafficLight.py
├── day-056
├── Example_HTTPError.py
├── Example_Request.py
├── Example_RobotFileParser.py
├── Example_URLError.py
├── Example_quote.py
├── Example_unquote.py
├── Example_urlencode.py
├── Example_urljoin.py
├── Example_urlopen.py
├── Example_urlparse.py
├── Example_urlsplit.py
├── Example_urlunparse.py
└── Example_urlunsplit.py
├── day-057
├── app.py
└── templates
│ ├── index.html
│ ├── login.html
│ └── signup.html
├── day-058-threadpool
└── ThreadPoolExecutor-demo.py
├── day-058
└── TestProject
│ ├── TestProject
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-37.pyc
│ │ ├── settings.cpython-37.pyc
│ │ ├── urls.cpython-37.pyc
│ │ └── wsgi.cpython-37.pyc
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
│ ├── db.sqlite3
│ ├── manage.py
│ └── polls
│ ├── __init__.py
│ ├── __pycache__
│ ├── __init__.cpython-37.pyc
│ ├── urls.cpython-37.pyc
│ └── views.cpython-37.pyc
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── day-059
└── TestProject
│ ├── TestProject
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-37.pyc
│ │ ├── settings.cpython-37.pyc
│ │ ├── urls.cpython-37.pyc
│ │ └── wsgi.cpython-37.pyc
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
│ ├── db.sqlite3
│ ├── manage.py
│ └── polls
│ ├── __init__.py
│ ├── __pycache__
│ ├── __init__.cpython-37.pyc
│ ├── admin.cpython-37.pyc
│ ├── apps.cpython-37.pyc
│ ├── models.cpython-37.pyc
│ ├── urls.cpython-37.pyc
│ └── views.cpython-37.pyc
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ ├── 0001_initial.py
│ ├── __init__.py
│ └── __pycache__
│ │ ├── 0001_initial.cpython-37.pyc
│ │ └── __init__.cpython-37.pyc
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── day-060
├── requests-base-complex-post.py
├── requests-base-complex.py
├── requests-base-cookie.py
├── requests-base-headers.py
├── requests-base-params.py
├── requests-base-redirect.py
├── requests-base-response-info.py
├── requests-base-response.py
├── requests-base-send-request.py
├── requests-base-simple.py
├── requests-base-timeout.py
└── test.txt
├── day-061
├── requests-high-auth.py
├── requests-high-session.py
└── requests-high-ssl.py
├── day-062
├── __init__.py
└── status_code.py
├── day-064
└── lxml.py
├── day-065
└── BeautifulSoup-demo-01.py
├── day-066
└── BeautifulSoup-demo-02.py
├── day-067
├── pyquery-css-selector.py
├── pyquery-find.py
├── pyquery-init.py
├── pyquery-pseudo.py
├── pyquery-request-params.py
├── pyquery-tag-info.py
└── test.html
├── day-068
└── chromedriver-test.py
├── day-069
├── selenium-browser-back-forward.py
├── selenium-browser-cookie.py
├── selenium-browser-tab.py
├── selenium-get-element.py
├── selenium-get-elements.py
├── selenium-implicit-wait.py
├── selenium-obvious-wait.py
├── selenium-open-browser-headless.py
├── selenium-open-browser.py
└── selenium-page-operations.py
├── day-070
├── itemcsvexporter.py
├── items.py
└── settings.py
├── day-071
└── FBP_Scrapy.py
├── day-072
├── crawlerdb.py
└── pysider.py
├── day-073
├── mychat1.py
└── mychat2.py
├── day-074
├── __init__.py
├── bg.jpg
├── newspaper_demo1.py
├── newspaper_demo2.py
└── wc.jpg
├── day-075-wxcrawl
└── WxCrawler.py
├── day-075
└── redis.py
├── day-076
├── github.py
├── github2.py
└── renren.py
├── day-077
├── __init__.py
└── sqlite_demo.py
├── day-078
├── mongodb.py
└── test.db
├── day-079
└── __init__.py
├── day-080
├── __init__.py
├── create_table.py
├── delete_data.py
├── insert_data.py
├── mysql_test.py
├── query_data.py
└── update_test.py
├── day-081
├── __init__.py
└── numpy_test.py
├── day-083-string-func
└── numpy-string-func.py
├── day-084-math-arith-func
├── numpy-math-arith-func.py
├── numpy-math-around-func.py
└── numpy-math-trigono-func.py
├── day-085-stat-func
└── numpy-stat-func.py
├── day-085
├── nnumpy-filter-func.py
├── numpy-sort-sort1-func.py
└── numpy-sort-sort2-func.py
├── day-086
├── __init__.py
├── foo.db
└── sqlalchemy_sqlite.py
├── day-088-flask-OAuth
├── app.py
└── templates
│ └── home.html
├── day-090-numpy
├── __init__.py
├── numpy_arthfunc.py
└── numpy_bitwise.py
├── day-091-matplotlib
├── __init__.py
├── matplotlib-exam1.py
└── matplotlib-exam2.py
├── day-092
├── MatPlotlib_test.py
├── Triangle_scat_chart.py
├── __init__.py
├── bar_chart.py
├── basic_exce.py
├── cosine_chart.py
├── curve_chart1.py
├── curve_chart2.py
├── line_chart.py
├── numpy_exam.py
├── opera-matplotlib.py
├── scatter_chart.py
├── sin_cos_chart.py
├── sine_chart.py
└── subplot
│ ├── __init__.py
│ ├── axes-2.py
│ ├── axes.py
│ ├── gridspec.py
│ ├── subplot-grid.py
│ ├── subplot-horizontal.py
│ ├── subplot-vertical.py
│ └── subplot_chart.py
├── day-093
└── app.py
├── day-094
└── __init__.py
├── day-096
├── cat.jpg
├── cat.png
├── flower.jpg
├── image-blend.py
├── image-change-suffix.py
├── image-composite.py
├── image-create.py
├── image-eval.py
├── image-merge.py
├── image-open.py
└── image-thumbnail.py
├── day-097
├── cat.jpg
├── cat.png
├── flower.jpg
├── image-band.py
├── image-bbox.py
├── image-convert.py
├── image-crop.py
├── image-filter.py
├── image-getcolors.py
├── image-point.py
└── image-resize.py
├── day-098
├── binary.png
├── clear_noisy.py
├── grey.png
├── result.png
└── vc.png
├── day-099
├── tcp-client.py
└── tcp-server.py
├── day-100-01
└── 三木板模型算法项目实战
├── day-100
├── udp-client.py
└── udp-server.py
├── day-101-01
├── FBP_ML_XGBClassifier.py
├── FBP_ML_XGBRegressor.py
└── Python XGBoost算法项目实战
├── day-101
├── simple_asyncio.py
├── single_callback_asyncio.py
├── task_asyncio.py
├── task_callback_asyncio.py
└── wait_asyncio.py
├── day-102-01
├── 1.2.1.py
├── 1.2.2.py
├── 2.2.1.py
├── 2.2.2.py
├── 2.2.3.py
├── 2.2.4.py
├── 2.2.5.py
├── 2.3.1.py
├── 2.3.2.py
└── 3.py
├── day-102
├── aiohttp_cookies.py
├── aiohttp_header.py
├── aiohttp_json.py
├── aiohttp_many.py
├── aiohttp_params.py
├── aiohttp_post.py
├── aiohttp_session.py
├── aiohttp_timeout.py
└── requests_many.py
├── day-103-01
├── 2.1-示例1.py
├── 2.1-示例2.py
├── 2.1-示例3.py
└── 2.2-示例.py
├── day-103
├── excel_r.py
├── excel_u.py
├── excel_w.py
└── excel_w2.py
├── day-104
├── __init__.py
├── test.xml
└── xml_demo.py
├── day-105
├── python_install.png
├── word1.docx
├── word2.docx
├── word_1.py
├── word_2.py
└── word_3.py
├── day-106
└── __init__.py
├── day-107-csv
├── 1-示例1.py
├── 1-示例2.py
├── 1-示例3.py
├── 1-示例4.py
├── 1-示例5.py
├── 1-示例6.py
├── 2.1-示例.py
├── 2.2-示例.py
├── 2.3-示例.py
├── 2.4-示例.py
├── 2.5-示例.py
├── 2.6-示例.py
├── 2.7-示例.py
├── 2.8-示例.py
└── 2.9-示例.py
├── day-107
├── pdf_1.py
├── pdf_2.py
└── pdfminer.pdf
├── day-108-csv
├── __init__.py
├── csv_demo.py
└── test.csv
├── day-108
├── 1-示例1.py
├── 1-示例2.py
├── 1-示例3.py
├── 2.1-示例.py
├── 2.10-示例.py
├── 2.2-示例.py
├── 2.3-示例.py
├── 2.4-示例.py
├── 2.5-示例.py
├── 2.6-示例.py
├── 2.7-示例.py
├── 2.8-示例.py
└── 2.9-示例.py
├── day-110
├── gc_ref_count1.py
├── gc_ref_count2.py
└── gc_ref_count3.py
├── day-111
├── param_demo1.py
├── param_demo2.py
└── param_demo3.py
├── day-112
├── MonteCarlo.py
├── MonteCarlo_integral.py
└── __init__.py
├── day-115
├── data.csv
└── nbm.py
├── day-117
├── Iris.csv
├── KNN.py
└── __init__.py
├── day-118
├── object_demo.py
└── object_demo2.py
├── day-119
├── douban-movie-top250.py
└── doubanTop250.txt
├── day-120
├── Iris.csv
├── __init__.py
└── clusters.py
├── day-121
└── dt.py
├── day-122
├── app.py
├── config.py
├── model.py
├── route.py
├── testApp.py
└── testBase.py
├── day-123
└── TestProject
│ ├── TestProject
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-37.pyc
│ │ ├── settings.cpython-37.pyc
│ │ ├── urls.cpython-37.pyc
│ │ └── wsgi.cpython-37.pyc
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
│ ├── db.sqlite3
│ ├── manage.py
│ └── polls
│ ├── __init__.py
│ ├── __pycache__
│ ├── __init__.cpython-37.pyc
│ ├── admin.cpython-37.pyc
│ ├── apps.cpython-37.pyc
│ ├── models.cpython-37.pyc
│ ├── urls.cpython-37.pyc
│ └── views.cpython-37.pyc
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ ├── 0001_initial.py
│ ├── __init__.py
│ └── __pycache__
│ │ ├── 0001_initial.cpython-37.pyc
│ │ └── __init__.cpython-37.pyc
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── day-124
└── TestProject
│ ├── TestProject
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-37.pyc
│ │ ├── settings.cpython-37.pyc
│ │ ├── urls.cpython-37.pyc
│ │ └── wsgi.cpython-37.pyc
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
│ ├── db.sqlite3
│ ├── manage.py
│ ├── polls
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-37.pyc
│ │ ├── admin.cpython-37.pyc
│ │ ├── apps.cpython-37.pyc
│ │ ├── models.cpython-37.pyc
│ │ ├── urls.cpython-37.pyc
│ │ └── views.cpython-37.pyc
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ │ ├── 0001_initial.py
│ │ ├── __init__.py
│ │ └── __pycache__
│ │ │ ├── 0001_initial.cpython-37.pyc
│ │ │ └── __init__.cpython-37.pyc
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
│ └── templates
│ ├── common.html
│ └── index.html
├── day-125
└── project
│ ├── __init__.py
│ ├── config.py
│ ├── data-dev.db
│ ├── data-test.db
│ ├── forms
│ └── myform.py
│ ├── models
│ ├── __init__.py
│ ├── profile.py
│ └── user.py
│ ├── routes
│ ├── __init__.py
│ ├── home.py
│ └── profile.py
│ └── templates
│ ├── createprofile.html
│ ├── index.html
│ └── profile.html
├── day-126
├── 2.py
├── 3.py
└── 4.py
├── day-127
├── 2.py
├── 3.py
├── 4.py
├── 5.py
└── 6.py
├── day-128
├── 2.py
├── 3.py
└── 4.py
├── day-130
├── myproject
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-37.pyc
│ │ └── config.cpython-37.pyc
│ └── config.py
├── requirements.txt
├── run.py
├── uwsgi.ini
└── uwsgi.pid
├── douban-movie-top250
├── doubanTop250.txt
├── douban_movie_top250_analysis-1.py
└── douban_movie_top250_analysis-2.py
├── feiyan_data
└── feiyan_data_any.py
├── ffmpeg
└── ffmpeg.py
├── flask_pyecharts
├── app.py
├── static
│ ├── echarts.min.js
│ └── jquery.min.js
└── templates
│ ├── index.html
│ ├── index2.html
│ └── pyecharts
│ ├── components.html
│ ├── macro
│ ├── nb_components.html
│ ├── nb_jupyter_globe.html
│ ├── nb_jupyter_lab.html
│ ├── nb_jupyter_lab_tab.html
│ ├── nb_jupyter_notebook.html
│ ├── nb_jupyter_notebook_tab.html
│ ├── nb_nteract.html
│ ├── simple_chart.html
│ ├── simple_globe.html
│ ├── simple_page.html
│ └── simple_tab.html
├── jobSkill
├── fenCi.py
├── job_crawl.py
└── pltBar.py
├── lagou
├── LgCrawler.py
└── jobs.sql
├── leetcode-089
└── leetcode89.py
├── populationone
├── anaone.py
└── populationone.py
├── populationtwo
├── anatwo.py
└── populationtwo.py
├── pythondocx
└── word.py
├── qrcode_demo
├── __init__.py
├── bg.jpg
├── gmqr.png
├── gmyqr.gif
├── gzh.jpg
├── my.gif
├── myqr.gif
├── myqr.png
├── myqr_demo.py
├── parseqr_demo.py
├── pmyqr.png
├── qr.jpg
└── qr_demo.py
├── timefriend
├── test.py
└── timefriend.py
└── wsfriends
├── alice.png
└── wxfriends.py
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | .DS_Store
3 |
--------------------------------------------------------------------------------
/anjia/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/anjia/__init__.py
--------------------------------------------------------------------------------
/anjia/anjia.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/anjia/anjia.png
--------------------------------------------------------------------------------
/anjia/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/anjia/bg.jpg
--------------------------------------------------------------------------------
/day-001/hello.py:
--------------------------------------------------------------------------------
1 | print("hello world!")
--------------------------------------------------------------------------------
/day-002/identifier.py:
--------------------------------------------------------------------------------
1 | print("hello");
2 | print("world");
3 |
--------------------------------------------------------------------------------
/day-002/indent.py:
--------------------------------------------------------------------------------
1 | if True:
2 | print("neo")
3 | else:
4 | print("smile")
--------------------------------------------------------------------------------
/day-002/print.py:
--------------------------------------------------------------------------------
1 | x="a"
2 | y="b"
3 | print(x, end=' ')
4 | print(y, end=' ')
--------------------------------------------------------------------------------
/day-003/Dictionary.py:
--------------------------------------------------------------------------------
1 | Logo_code = {
2 | 'BIDU':'Baidu',
3 | 'SINA':'Sina',
4 | 'YOKU':'Youku'
5 | }
6 | print(Logo_code)
7 | # 输出{'BIDU': 'Baidu', 'YOKU': 'Youku', 'SINA': 'Sina'}
8 | print (Logo_code['SINA']) # 输出键为 'one' 的值
9 | print (Logo_code.keys()) # 输出所有键
10 | print (Logo_code.values()) # 输出所有值
11 | print (len(Logo_code)) # 输出字段长度
--------------------------------------------------------------------------------
/day-003/List.py:
--------------------------------------------------------------------------------
1 | Weekday = ['Monday','Tuesday','Wednesday','Thursday','Friday']
2 | print(Weekday[0]) # 输出 Monday
3 |
4 | #list 搜索
5 | print(Weekday.index("Wednesday"))
6 |
7 | #list 增加元素
8 | Weekday.append("new")
9 | print(Weekday)
10 |
11 | # list 删除
12 | Weekday.remove("Thursday")
13 | print(Weekday)
--------------------------------------------------------------------------------
/day-003/Sets.py:
--------------------------------------------------------------------------------
1 | a_set = {1,2,3,4}
2 | # 添加
3 | a_set.add(5)
4 | print(a_set) # 输出{1, 2, 3, 4, 5}
5 | # 删除
6 | a_set.discard(5)
7 | print(a_set) # 输出{1, 2, 3, 4}
8 |
--------------------------------------------------------------------------------
/day-003/Tuple.py:
--------------------------------------------------------------------------------
1 | letters = ('a','b','c','d','e','f','g')
2 | print(letters[0]) # 输出 'a'
3 | print(letters[0:3]) # 输出一组 ('a', 'b', 'c')
4 |
--------------------------------------------------------------------------------
/day-003/number.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | counter = 100 # 整型变量
4 | miles = 1000.0 # 浮点型变量
5 | name = "test" # 字符串
6 |
7 | print (counter)
8 | print (miles)
9 | print (name)
10 |
11 | print (5 + 4) # 加法 输出 9
12 | print (4.3 - 2) # 减法 输出 2.3
13 | print (3 * 7) # 乘法 输出 21
14 | print (2 / 4) # 除法,得到一个浮点数 输出 0.5
15 | print (2 // 4) # 除法,得到一个整数 输出 0
16 | print (17 % 3) # 取余 输出 2
17 | print (2 ** 5) # 乘方 输出 32
--------------------------------------------------------------------------------
/day-003/variable.py:
--------------------------------------------------------------------------------
1 | name = "neo"
2 | print (name)
3 |
4 | a, b, c = 1, 2, "neo"
5 | print (a)
6 | print (b)
7 | print (c)
--------------------------------------------------------------------------------
/day-004/break.py:
--------------------------------------------------------------------------------
1 | for letter in 'ityouknow': # 第一个实例
2 | if letter == 'n': # 字母为 n 时中断
3 | break
4 | print ('当前字母 :', letter)
--------------------------------------------------------------------------------
/day-004/continue.py:
--------------------------------------------------------------------------------
1 | for letter in 'ityouknow': # 第一个实例
2 | if letter == 'n': # 字母为 n 时跳过输出
3 | continue
4 | print ('当前字母 :', letter)
--------------------------------------------------------------------------------
/day-004/for.py:
--------------------------------------------------------------------------------
1 | for letter in 'Python': # 第一个实例
2 | print('当前字母 :', letter)
3 |
4 | fruits = ['banana', 'apple', 'mango']
5 | for fruit in fruits: # 第二个实例
6 | print('当前水果 :', fruit)
7 |
8 | print("Good bye!")
9 |
10 |
11 |
12 | # 通过索引循环
13 |
14 | fruits = ['banana', 'apple', 'mango']
15 | for index in range(len(fruits)):
16 | print('当前水果 :', fruits[index])
17 |
18 | print("Good bye!")
--------------------------------------------------------------------------------
/day-004/if.py:
--------------------------------------------------------------------------------
1 | #x = int(input("Please enter an integer: "))
2 | x = -5
3 | if x < 0:
4 | x = 0
5 | print('Negative changed to zero')
6 | elif x == 0:
7 | print('Zero')
8 | elif x == 1:
9 | print('Single')
10 | else:
11 | print('More')
--------------------------------------------------------------------------------
/day-004/pass.py:
--------------------------------------------------------------------------------
1 | while True:
2 | pass # Busy-wait for keyboard interrupt (Ctrl+C)
3 |
4 |
5 | # 这通常用于创建最小结构的类:
6 |
7 | class MyEmptyClass:
8 | pass
9 |
--------------------------------------------------------------------------------
/day-004/range.py:
--------------------------------------------------------------------------------
1 | for i in range(6):
2 | print(i)
3 | print(range(6),'finish')
4 |
5 | for i in range(6,10):
6 | print(i)
7 | print(range(6,10),'finish')
8 |
9 | for i in range(6,12,2):
10 | print(i)
11 | print(range(6,12,2),'finish')
12 |
13 |
14 | # 迭代链表
15 | a = ['i', 'love', 'coding', 'and', 'free']
16 | for i in range(len(a)):
17 | print(i, a[i])
--------------------------------------------------------------------------------
/day-004/while.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | count = 0
4 | while (count < 9):
5 | print('The count is:', count)
6 | count = count + 1
7 |
8 | print("Good bye!")
9 |
10 | count = 0
11 | while count < 6:
12 | print(count, " is less than 6")
13 | count = count + 1
14 | else:
15 | print(count, " is not less than 6")
--------------------------------------------------------------------------------
/day-006/cal/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-006/cal/__init__.py
--------------------------------------------------------------------------------
/day-006/cal/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-006/cal/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-006/cal/__pycache__/calculator.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-006/cal/__pycache__/calculator.cpython-37.pyc
--------------------------------------------------------------------------------
/day-006/cal/calculator.py:
--------------------------------------------------------------------------------
1 | def add(a,b) :
2 | return a+b
3 |
4 | def reduce(a,b) :
5 | return a-b
6 |
7 | def multiply(a,b) :
8 | return a*b
9 |
10 | def divide(a,b) :
11 | return a/b
--------------------------------------------------------------------------------
/day-006/do.py:
--------------------------------------------------------------------------------
1 | # 导入模块
2 | import hello
3 |
4 | # 现在可以调用模块里包含的函数了
5 | hello.sayhello()
6 |
7 |
8 | ## 直接导入方法
9 | from hello import sayhello
10 | sayhello()
11 |
12 |
13 |
14 | ## 导入所有方法
15 | from hello import *
16 | sayhello()
17 | world()
18 |
19 |
20 | print("测试包的使用")
21 |
22 | import cal.calculator
23 | print(cal.calculator.add(1,2))
24 |
25 |
26 | from cal import calculator
27 | # 使用包的模块的方法
28 | print(calculator.multiply(3,6))
--------------------------------------------------------------------------------
/day-006/hello.py:
--------------------------------------------------------------------------------
1 | def sayhello():
2 | print("Hello World!")
3 |
4 | def world():
5 | print("Python World!")
--------------------------------------------------------------------------------
/day-007/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-007/__init__.py
--------------------------------------------------------------------------------
/day-008/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-008/__init__.py
--------------------------------------------------------------------------------
/day-009/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-009/__init__.py
--------------------------------------------------------------------------------
/day-010/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-010/__init__.py
--------------------------------------------------------------------------------
/day-011/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-011/__init__.py
--------------------------------------------------------------------------------
/day-011/dict_fromkeys.py:
--------------------------------------------------------------------------------
1 |
2 | # dict.fromkeys(seq[, value])
3 | seq = ('name', 'age', 'class')
4 |
5 | #
6 | dict = dict.fromkeys(seq)
7 | print("新的字典为 : %s" % str(dict))
8 |
9 | dict = dict.fromkeys(seq, 10)
10 | print("新的字典为 : %s" % str(dict))
11 |
12 | dict = dict.fromkeys(seq,('zs',8,'Two'))
13 | print("新的字典为 : %s" % str(dict))
--------------------------------------------------------------------------------
/day-011/dictionary-in.py:
--------------------------------------------------------------------------------
1 | dict = {'Name': 'Mary', 'Age': 20,'Address':'BeiJing'}
2 |
3 | # 检测键 Age 是否存在
4 | if 'Age' in dict:
5 | print("键 Age 存在")
6 | else:
7 | print("键 Age 不存在")
8 |
9 | # 检测键 Sex 是否存在
10 | if 'Sex' in dict:
11 | print("键 Sex 存在")
12 | else:
13 | print("键 Sex 不存在")
14 |
15 | # not in
16 |
17 | # 检测键 Name 是否存在
18 | if 'Name' not in dict:
19 | print("键 Name 不存在")
20 | else:
21 | print("键 Name 存在")
--------------------------------------------------------------------------------
/day-011/dictionary_copy.py:
--------------------------------------------------------------------------------
1 | # !/usr/bin/python
2 |
3 | dict = {'Name': 'Runoob', 'Age': 7, 'Class': 'First'}
4 |
5 | dict11 = dict.copy()
6 | print(dict)
7 | print("新复制的字典为 : ", dict11)
8 |
9 | dict1 = {'user': 'runoob', 'num': [1, 2, 3]}
10 |
11 | dict2 = dict1 # 浅拷贝: 引用对象
12 | dict3 = dict1.copy() # 浅拷贝:深拷贝父对象(一级目录),子对象(二级目录)不拷贝,还是引用
13 |
14 | # 修改 data 数据
15 | dict1['user'] = 'root'
16 | dict1['num'].remove(1)
17 |
18 | # 输出结果
19 | print(dict1)
20 | print(dict2)
21 | print(dict3)
22 |
--------------------------------------------------------------------------------
/day-011/dictionary_del.py:
--------------------------------------------------------------------------------
1 | # 删除字典元素
2 | dict = {'Name': 'Fiona', 'Age': 10, 'Class': 'Three'}
3 |
4 | # 删除键是'Name'的条目
5 | del dict['Name']
6 |
7 | # 清空字典所有条目
8 | dict.clear()
9 |
10 | # 删除整个字典
11 | del dict
12 |
13 | print("dict['Age']: ", dict['Age'])
14 | print("dict['School']: ", dict['School'])
--------------------------------------------------------------------------------
/day-011/dictionary_get.py:
--------------------------------------------------------------------------------
1 |
2 | # get ()方法的应用举例
3 | dict = {'Name': 'Mary', 'Age': 20}
4 |
5 | print ("Age 值为 : %s" % dict.get('Age'))
6 | print ("Name 值为 : %s" % dict.get('Name'))
7 | print ("Sex 值为 : %s" % dict.get('Sex', "NA"))
8 |
--------------------------------------------------------------------------------
/day-011/dictionary_items.py:
--------------------------------------------------------------------------------
1 |
2 | dict = {'Name': 'Mary', 'Age': 17}
3 |
4 | print("Value : %s" % dict.items())
5 |
6 |
7 | # 可遍历实例
8 | dict1 = {'老大':'15岁',
9 | '老二':'14岁',
10 | '老三':'2岁',
11 | }
12 | print(dict1.items())
13 | for key,values in dict1.items():
14 | print(key + '已经' + values + '了')
15 |
16 |
17 |
--------------------------------------------------------------------------------
/day-011/dictionary_keys.py:
--------------------------------------------------------------------------------
1 | dict = {'Name': 'Mary', 'Age': 17}
2 |
3 | print(dict.keys())
4 |
5 | list1 = list(dict.keys())
6 | print ("转换后的结果为 : %s" % list1)
7 |
--------------------------------------------------------------------------------
/day-011/dictionary_pop.py:
--------------------------------------------------------------------------------
1 |
2 | dict = {'Name': 'Mary', 'Age': 17}
3 |
4 | result = dict.pop('Age') # 删除 键为 Name 的键值对
5 |
6 | print(result)
--------------------------------------------------------------------------------
/day-011/dictionary_popitem.py:
--------------------------------------------------------------------------------
1 |
2 | dict = {'Name': 'Mary', 'Age': 17}
3 | pop_obj=dict.popitem()
4 | print(pop_obj)
5 | print(dict)
6 |
7 | # 删除字典中的值
8 | del dict
9 |
10 | print(dict.popitem())
--------------------------------------------------------------------------------
/day-011/dictionary_setdefault.py:
--------------------------------------------------------------------------------
1 | dict = {'Name': 'Mary', 'Age': 17}
2 |
3 | print("Age 键的值为 : %s" % dict.setdefault('Age', None))
4 | print("Sex 键的值为 : %s" % dict.setdefault('Sex', None))
5 | print("新字典为:", dict)
6 |
--------------------------------------------------------------------------------
/day-011/dictionary_update.py:
--------------------------------------------------------------------------------
1 | dict = {'Name': 'Mary', 'Age': 17}
2 | dict2 = {'Sex': 'female'}
3 |
4 | dict.update(dict2)
5 | print("更新字典 dict : ", dict)
--------------------------------------------------------------------------------
/day-011/dictionary_values.py:
--------------------------------------------------------------------------------
1 |
2 | dict = { 'Name': 'Mary','Sex': 'male', 'Age': 7}
3 |
4 | print("字典所有值为 : ", list(dict.values()))
--------------------------------------------------------------------------------
/day-012/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-012/__init__.py
--------------------------------------------------------------------------------
/day-012/find_max_of_number.py:
--------------------------------------------------------------------------------
1 | def findMaxofNumber():
2 | '''
3 | 打印并返回 Python 常量池中的最大数值
4 | '''
5 | for b in range(300):
6 | if b is not range(300)[b]:
7 | print("常量池最大值为:", (b - 1))
8 | return (b - 1)
9 |
10 | if __name__ == '__main__':
11 | findMaxofNumber()
--------------------------------------------------------------------------------
/day-013/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-013/__init__.py
--------------------------------------------------------------------------------
/day-015/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-015/__init__.py
--------------------------------------------------------------------------------
/day-015/set_difference.py:
--------------------------------------------------------------------------------
1 |
2 | # 求两个集合的差集,元素在 x 中不在 y 中
3 | x = {"apple", "banana", "cherry"}
4 | y = {"google", "microsoft", "apple"}
5 |
6 | z = x.difference(y)
7 |
8 | print('两个集合的差集是:%s' % z)
--------------------------------------------------------------------------------
/day-015/set_difference_update.py:
--------------------------------------------------------------------------------
1 |
2 | # 移除两个集合中都存在的元素,无返回值,将 x 中存在的 y 中不存在的留下,将 x 和 y 中都存在的删除,y 中存在和不存在的删除
3 | x = {"apple", "banana", "cherry"}
4 | y = {"google", "microsoft", "apple"}
5 |
6 | x.difference_update(y)
7 |
8 | print(x)
9 |
10 |
11 | x1 = {1,2,3,4}
12 | y1 = {1,2,3}
13 |
14 | x1.difference_update(y1)
15 |
16 | print(x1)
--------------------------------------------------------------------------------
/day-015/set_intersection.py:
--------------------------------------------------------------------------------
1 |
2 | # 返回两个或者多个集合的交集
3 | x = {"apple", "banana", "cherry"}
4 | y = {"google", "runoob", "apple"}
5 |
6 | z = x.intersection(y)
7 |
8 | print(z)
9 |
10 | # 返回三个集合的交集
11 | x = {"a", "b", "c"}
12 | y = {"c", "d", "e"}
13 | z = {"f", "g", "c"}
14 |
15 | result = x.intersection(y, z)
16 | print('三个集合的差集是:%s' % result)
--------------------------------------------------------------------------------
/day-015/set_intersection_update.py:
--------------------------------------------------------------------------------
1 | # 返回一个无返回值的集合交集
2 | x = {"apple", "banana", "cherry"}
3 | y = {"google", "runoob", "apple"}
4 |
5 | x.intersection_update(y)
6 |
7 | print(x)
8 |
9 | x = {"a", "b", "c"}
10 | y = {"c", "d", "e"}
11 | z = {"f", "g", "c"}
12 |
13 | x.intersection_update(y, z)
14 |
15 | print(x)
--------------------------------------------------------------------------------
/day-015/set_isdisjoint.py:
--------------------------------------------------------------------------------
1 | x = {"apple", "banana", "cherry"}
2 | y = {"google", "runoob", "apple"}
3 | # 判断集合 y 中是否包含集合 x 中的元素,如果没有返回 True, 有则返回 False
4 | z = x.isdisjoint(y)
5 | # 结果返回 False,说明集合 y 中有和 x 中相同的元素
6 | print(z)
7 |
8 |
9 |
10 | x = {"apple", "banana", "cherry"}
11 | y = {"google", "runoob", "baidu"}
12 | # 判断集合 y 中是否包含集合 x 中的元素,如果没有返回 True, 有则返回 False
13 | z = x.isdisjoint(y)
14 | # 结果返回 True,说明集合 y 中没有和 x 中相同的元素
15 | print(z)
--------------------------------------------------------------------------------
/day-015/set_issubset.py:
--------------------------------------------------------------------------------
1 |
2 | # 判断集合 x 的所有元素是否都包含在集合 y 中:
3 | x = {"a", "b", "c"}
4 | y = {"f", "e", "d", "c", "b", "a"}
5 |
6 | z = x.issubset(y)
7 |
8 | print(z)
9 |
10 | x = {"a", "b", "c"}
11 | y = {"f", "e", "d", "c", "b","y"}
12 |
13 | z = x.issubset(y)
14 |
15 | print(z)
--------------------------------------------------------------------------------
/day-015/set_issuperset.py:
--------------------------------------------------------------------------------
1 | x = {"f", "e", "d", "c", "b", "a"}
2 | y = {"a", "b", "c"}
3 |
4 | z = x.issuperset(y)
5 |
6 | print(z)
7 |
8 | # 如果没有全部包含返回 False:
9 | x = {"f", "e", "d", "c", "b"}
10 | y = {"a", "b", "c"}
11 |
12 | z = x.issuperset(y)
13 |
14 | print(z)
--------------------------------------------------------------------------------
/day-015/set_symmetric_difference.py:
--------------------------------------------------------------------------------
1 |
2 | # 返回两个集合组成的新集合,但会移除两个集合的重复元素:
3 | x = {"apple", "banana", "cherry"}
4 | y = {"google", "runoob", "apple"}
5 |
6 | z = x.symmetric_difference(y)
7 |
8 | print(z)
--------------------------------------------------------------------------------
/day-015/set_union.py:
--------------------------------------------------------------------------------
1 | # 合并两个集合,重复元素只会出现一次:
2 |
3 | x = {"apple", "banana", "cherry"}
4 | y = {"google", "runoob", "apple"}
5 |
6 | z = x.union(y)
7 |
8 | print(z)
9 |
10 |
11 | # 合并多个集合:
12 |
13 | x = {"a", "b", "c"}
14 | y = {"f", "d", "a"}
15 | z = {"c", "d", "e"}
16 |
17 | result = x.union(y, z)
18 |
19 | print(result)
--------------------------------------------------------------------------------
/day-015/symmetric_difference_update.py:
--------------------------------------------------------------------------------
1 |
2 | # 在原始集合 x 中移除与 y 集合中的重复元素,并将不重复的元素插入到集合 x 中:
3 | x = {"apple", "banana", "cherry"}
4 | y = {"google", "runoob", "apple"}
5 |
6 | x.symmetric_difference_update(y)
7 |
8 | print(x)
--------------------------------------------------------------------------------
/day-017/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-017/__init__.py
--------------------------------------------------------------------------------
/day-017/template.py:
--------------------------------------------------------------------------------
1 | from flask import Flask # 引入Flask模块
2 | from flask import render_template # 引入Jinja2模板
3 |
4 | app = Flask(__name__)
5 |
6 | @app.route('/')
7 | def index():
8 | return render_template('hello.html', name=(1,2,3,4))
9 |
10 | @app.route('/template/')
11 | def template():
12 | name = 'Jinja2 模板引擎'
13 | myindex = 1
14 | mylist = [1,2,3,4]
15 | mydict = {
16 | 'key': 'age',
17 | 'value': '25'
18 | }
19 | mytuple = (1,2,3,4)
20 | return render_template('template.html', name=name, myindex=myindex, mylist=mylist, mydict=mydict, mytuple=mytuple)
21 |
22 |
23 | if __name__ == "__main__":
24 | app.run()
--------------------------------------------------------------------------------
/day-017/templates/hello.html:
--------------------------------------------------------------------------------
1 |
Hello {{ name[0] }}
--------------------------------------------------------------------------------
/day-017/templates/template.html:
--------------------------------------------------------------------------------
1 | A value form a string: {{ name }}.
2 | A value form a int: {{ myindex }}.
3 | A value form a list: {{ mylist[3] }}.
4 | A value form a list, with a variable index: {{ mylist[myindex] }}.
5 | A value form a dictionary: {{ mydict['key'] }}.
6 | A value form a tuple: {{ mytuple }}.
7 | A value form a tuple by index: {{ mytuple[myindex] }}.
--------------------------------------------------------------------------------
/day-017/templates/新建文本文档.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-017/templates/新建文本文档.txt
--------------------------------------------------------------------------------
/day-018/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-018/__init__.py
--------------------------------------------------------------------------------
/day-018/filter.py:
--------------------------------------------------------------------------------
1 | # -*-coding:UTF-8-*-
2 |
3 |
4 | def boy(n):
5 | if n % 2 == 0:
6 | return True
7 | return False
8 |
9 | # 自定义函数
10 | filterList = filter(boy, list(range(20)))
11 |
12 | print(list(filterList))
13 | # print out: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
14 |
15 | # 自定义函数
16 | filterList2 = filter(lambda n: n % 2 == 0, list(range(20)))
17 |
18 | print(list(filterList2))
19 | # print out: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
20 |
21 |
--------------------------------------------------------------------------------
/day-018/map.py:
--------------------------------------------------------------------------------
1 | # -*-coding:UTF-8-*-
2 | from math import factorial
3 |
4 |
5 | def square(n):
6 | return n ** 2
7 |
8 | # 使用python自带数学函数
9 | facMap = map(factorial, list(range(10)))
10 | print(list(facMap))
11 | # print out: [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]
12 |
13 | # 使用自定义函数
14 | squareMap = map(square, list(range(10)))
15 | print(list(squareMap))
16 | # print out: [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
17 |
18 | # 使用匿名函数
19 | lamMap = map(lambda x: x * 2, list(range(10)))
20 | print(list(lamMap))
21 | # print out: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
22 |
23 | # 传入多个序列
24 | mutiMap = map(lambda x, y: x+y, list(range(10)), list(range(11, 15)))
25 | print(list(mutiMap))
26 | # print out: [11, 13, 15, 17]
27 |
28 |
--------------------------------------------------------------------------------
/day-018/reduce.py:
--------------------------------------------------------------------------------
1 | # -*-coding:UTF-8-*-
2 | from functools import reduce
3 |
4 | result = reduce(lambda x, y: x + y, [1, 2, 3, 4, 5])
5 |
6 | print(result)
7 | # print out: 15
8 |
9 |
10 | # 设定初始参数:
11 | s = reduce(lambda x, y: x + y, ['1', '2', '3', '4', '5'], "数字 = ")
12 |
13 | print(s)
14 | # print out: 数字 = 12345
15 |
16 |
17 | error = reduce(lambda x, y: x + y, [1, 2, 3, 4, 5], "数字 = ")
18 |
19 | print(error)
20 | # TypeError: can only concatenate str (not "int") to str
21 |
22 |
--------------------------------------------------------------------------------
/day-018/sorted.py:
--------------------------------------------------------------------------------
1 | # -*-coding:UTF-8-*-
2 |
3 | list01 = [5, -1, 3, 6, -7, 8, -11, 2]
4 | list02 = ['apple', 'pig', 'monkey', 'money']
5 |
6 | print(sorted(list01))
7 | # print out: [-11, -7, -1, 2, 3, 5, 6, 8]
8 |
9 | print(sorted(list01, key=abs))
10 | # print out: [-1, 2, 3, 5, 6, -7, 8, -11]
11 |
12 | # 默认升序
13 | print(sorted(list02))
14 | # print out: ['apple', 'money', 'monkey', 'pig']
15 |
16 | # 降序
17 | print(sorted(list02, reverse=True))
18 | # print out: ['pig', 'monkey', 'money', 'apple']
19 |
20 | # 匿名函数排序
21 | print(sorted(list02, key=lambda x: len(x), reverse=True))
22 | # print out: ['monkey', 'apple', 'money', 'pig']
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/day-019/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-019/__init__.py
--------------------------------------------------------------------------------
/day-019/createIterator.py:
--------------------------------------------------------------------------------
1 | class Reverse:
2 | """反向遍历序列对象的迭代器"""
3 | def __init__(self, data):
4 | self.data = data
5 | self.index = len(data)
6 |
7 | def __iter__(self):
8 | return self
9 |
10 | def __next__(self):
11 | if self.index == 0:
12 | raise StopIteration
13 | self.index = self.index - 1
14 | return self.data[self.index]
15 |
16 |
17 | if __name__ == "__main__":
18 | rev = Reverse('justdopython.com')
19 | while True:
20 | try:
21 | print(next(rev))
22 | except StopIteration as identifier:
23 | print("Iteration stopped.")
24 | break
25 |
--------------------------------------------------------------------------------
/day-020/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-020/__init__.py
--------------------------------------------------------------------------------
/day-021/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-021/.DS_Store
--------------------------------------------------------------------------------
/day-021/templates/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | {% block head %}
4 | {% block title %}{% endblock%} - My Application
5 | {% endblock %}
6 |
7 |
8 | {% block body %}
9 | 这是基类的内容
10 | {% endblock %}
11 |
12 |
--------------------------------------------------------------------------------
/day-021/templates/filter.html:
--------------------------------------------------------------------------------
1 | {{ data1 | default(1, true) }}
2 |
3 |
4 | Hello {{ name | default('world')}}!
5 |
6 |
7 | Hello {{ name | default('world', true) }}
8 |
9 |
10 | 列表 {{ list }} 中的最小值是: {{ list | min }}
11 | 列表 {{ list }} 中的最大值是: {{ list | max }}
12 |
--------------------------------------------------------------------------------
/day-021/templates/for.html:
--------------------------------------------------------------------------------
1 | {% import 'mymarco.html' as macros %}
2 |
3 | {% for name in names %}
4 | {{ name }}
5 | {% endfor %}
6 |
7 |
8 |
9 | {% for name in names %}
10 | {{ macros.render_name(name) }}
11 | {% endfor %}
12 |
--------------------------------------------------------------------------------
/day-021/templates/hello2.html:
--------------------------------------------------------------------------------
1 | {% if gender=='male' %}
2 | Hello, Mr {{ name }}
3 | {% else %}
4 | Hello, Ms {{ name }}
5 | {% endif %}
--------------------------------------------------------------------------------
/day-021/templates/hello3.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% block title %}Index{% endblock %}
3 | {% block head %}
4 | {{ super() }}
5 |
6 | {% endblock %}
7 | {% block body %}
8 | {{ super() }}
9 | 这是子类的内容 Hello world!
10 | {% endblock %}
--------------------------------------------------------------------------------
/day-021/templates/index.html:
--------------------------------------------------------------------------------
1 | {{ name | capitalize }}
2 | You're name is {{ html | safe }}.
--------------------------------------------------------------------------------
/day-021/templates/json.html:
--------------------------------------------------------------------------------
1 | {{ data1 | default(1, true) }}
2 |
3 |
4 | Hello {{ name | default('world')}}!
5 |
6 |
7 | Hello {{ name | default('world', true) }}
8 |
9 |
10 | 列表 {{ list }} 中的最小值是: {{ list | min }}
11 | 列表 {{ list }} 中的最大值是: {{ list | max }}
12 |
--------------------------------------------------------------------------------
/day-021/templates/marco.html:
--------------------------------------------------------------------------------
1 | {% macro render_name(name) %}
2 | {{ name }}
3 | {% endmacro %}
--------------------------------------------------------------------------------
/day-021/templates/myfilter.html:
--------------------------------------------------------------------------------
1 | 电话号码是:{{ phone }}, 长度为:{{ phone | mylen }},运营商号:{{ phone | interval(0,3) }}
--------------------------------------------------------------------------------
/day-021/templates/mymarco.html:
--------------------------------------------------------------------------------
1 | {% macro render_name(name) %}
2 | {{ name }}
3 | {% endmacro %}
4 | mymarcoM
5 |
6 | {% for name in names %}
7 | {{ render_name(name) }}
8 | {% endfor %}
9 |
--------------------------------------------------------------------------------
/day-022/python_namespace.py:
--------------------------------------------------------------------------------
1 | # var1 是全局名称
2 | var1 = 5
3 |
4 | def some_func():
5 | # var2 是局部名称
6 | var2 = 6
7 |
8 | def some_inner_func():
9 | # var3 是内嵌的局部名称
10 | var3 = 7
11 |
12 |
--------------------------------------------------------------------------------
/day-024/standard_lib02.py:
--------------------------------------------------------------------------------
1 | from reprlib import recursive_repr
2 | class MyList(list):
3 | @recursive_repr()
4 | def __repr__(self):
5 | return '<' + '|'.join(map(repr, self)) + '>'
6 | m = MyList('abc')
7 | m.append(m)
8 | m.append('x')
9 | print(m)
10 |
11 |
12 | # 递归实例演示
13 | import reprlib
14 | a = [1,2,3,[4,5],6,7]
15 | reprlib.aRepr.maxlevel = 1
16 | print(reprlib.repr(a))
17 |
18 |
19 | # array 模块实例
20 | from array import array
21 | a = array('H', [4000, 10, 700, 22222])
22 | print(sum(a))
23 | print(array('H', [10, 700]))
24 |
25 |
--------------------------------------------------------------------------------
/day-026/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-026/__init__.py
--------------------------------------------------------------------------------
/day-026/os_example.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | # 打印系统型号
4 | print("打印系统型号")
5 | print(os.name)
6 | print()
7 |
8 | # 打印环境变量
9 | print("打印环境变量")
10 | for item in os.environ:
11 | print(item, ": ", os.environ[item])
12 | print()
13 |
14 | # 获取当前目录下全部文件名的函数
15 | def get_filelists(file_dir='.'):
16 | list_directory = os.listdir(file_dir)
17 | filelists = []
18 | for directory in list_directory:
19 | # os.path 模块稍后会讲到
20 | if(os.path.isfile(directory)):
21 | filelists.append(directory)
22 | return filelists
--------------------------------------------------------------------------------
/day-027/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-027/__init__.py
--------------------------------------------------------------------------------
/day-027/folder1/fdst.txt:
--------------------------------------------------------------------------------
1 | Hello shutil
--------------------------------------------------------------------------------
/day-027/folder1/fsrc.txt:
--------------------------------------------------------------------------------
1 | Hello shutil
--------------------------------------------------------------------------------
/day-027/tmp/fsrc.txt:
--------------------------------------------------------------------------------
1 | Hello shutil
--------------------------------------------------------------------------------
/day-028/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-028/__init__.py
--------------------------------------------------------------------------------
/day-028/count_log.txt:
--------------------------------------------------------------------------------
1 | count = 0
2 | count = 1
3 | count = 2
4 | count = 3
5 | count = 4
6 | count = 5
7 | count = 6
8 | count = 7
9 | count = 8
10 | count = 9
11 |
--------------------------------------------------------------------------------
/day-028/hello_python.txt:
--------------------------------------------------------------------------------
1 | Hello Python!
2 | Just do Python, go~
3 |
4 | Go, Go, GO!
--------------------------------------------------------------------------------
/day-028/sys_argv_example.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 |
4 | print("The list of command line arguments:\n", sys.argv)
5 |
--------------------------------------------------------------------------------
/day-028/sys_path_example.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 |
4 | print("The path[0] = ", sys.path[0])
--------------------------------------------------------------------------------
/day-028/sys_stdin_example.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 |
4 | # 使用 with 语句打开文件对象,使其可以自动关闭
5 | with open('hello_python.txt', 'r', encoding='utf-8') as f:
6 | sys.stdin = f
7 | try:
8 | # 一直输出输入流中的内容
9 | while True:
10 | print(input())
11 |
12 | # 若遇文件结束标识则退出
13 | except EOFError:
14 | exit()
--------------------------------------------------------------------------------
/day-028/sys_stdout_example.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 |
4 | # 以附加模式打开文件,若不存在则新建
5 | with open("count_log.txt", 'a', encoding='utf-8') as f:
6 | sys.stdout = f
7 | for i in range(10):
8 | print("count = ", i)
--------------------------------------------------------------------------------
/day-029/Queue.empty2.2.py:
--------------------------------------------------------------------------------
1 | import queue
2 | q = queue.Queue()
3 | print(q.empty()) # 对列为空,返回 True
4 | q.put('python-100') # 在队列中插入元素 'python-100'
5 | print(q.empty()) # 对列不为空,返回 False
--------------------------------------------------------------------------------
/day-029/Queue.full2.3.py:
--------------------------------------------------------------------------------
1 | import queue
2 | q = queue.Queue(3) # 定义一个长度为3的队列
3 | print(q.full()) # 元素个数未达到上限,返回 False
4 | q.put('python') # 在队列中插入字符串 'python'
5 | q.put('-') # 在队列中插入字符串 '-'
6 | q.put('100') # 在队列中插入字符串 '100'
7 | print(q.full()) # 元素个数达到上限,返回 True
--------------------------------------------------------------------------------
/day-029/Queue.get.py:
--------------------------------------------------------------------------------
1 | import queue
2 | try:
3 | q = queue.Queue()
4 | q.get(block = True, timeout = 5) # 队列为空,往队列中取数据时,等待5秒后会引发 queue.Empty 异常
5 | except queue.Empty:
6 | print('queue.Empty')
--------------------------------------------------------------------------------
/day-029/Queue.get_nowait.py:
--------------------------------------------------------------------------------
1 | import queue
2 | try:
3 | q = queue.Queue()
4 | q.get_nowait() # 队列为空,往队列中取数据时直接引发 queue.Empty 异常
5 | except queue.Empty:
6 | print('queue.Empty')
--------------------------------------------------------------------------------
/day-029/Queue.put.py:
--------------------------------------------------------------------------------
1 | import queue
2 | try:
3 | q = queue.Queue(2) # 设置队列上限为2
4 | q.put('python') # 在队列中插入字符串 'python'
5 | q.put('-') # 在队列中插入字符串 '-'
6 | q.put('100', block = True, timeout = 5) # 队列已满,继续在队列中插入字符串 '100',等待5秒后会引发 queue.Full 异常
7 | except queue.Full:
8 | print('queue.Full')
--------------------------------------------------------------------------------
/day-029/Queue.put_nowait.py:
--------------------------------------------------------------------------------
1 | import queue
2 | try:
3 | q = queue.Queue(2) # 设置队列上限为2
4 | q.put_nowait('python') # 在队列中插入字符串 'python'
5 | q.put_nowait('-') # 在队列中插入字符串 '-'
6 | q.put_nowait('100') # 队列已满,继续在队列中插入字符串 '100',直接引发 queue.Full 异常
7 | except queue.Full:
8 | print('queue.Full')
--------------------------------------------------------------------------------
/day-029/Queue.qsize.py:
--------------------------------------------------------------------------------
1 | import queue
2 | q = queue.Queue()
3 | q.put('python-100') # 在队列中插入元素 'python-100'
4 | print(q.qsize()) # 输出队列中元素个数为1
--------------------------------------------------------------------------------
/day-029/join-task_done1.py:
--------------------------------------------------------------------------------
1 | import queue
2 | q = queue.Queue()
3 | q.put('python')
4 | q.put('-')
5 | q.put('100')
6 | for i in range(3):
7 | print(q.get())
8 | q.task_done() # 如果不执行 task_done,join 会一直处于阻塞状态,等待 task_done 告知它数据的处理已经完成
9 | q.join()
10 |
11 |
--------------------------------------------------------------------------------
/day-029/queue.Empty.py:
--------------------------------------------------------------------------------
1 | import queue
2 | try:
3 | q = queue.Queue(3) # 设置队列上限为3
4 | q.put('python') # 在队列中插入字符串 'python'
5 | q.put('-') # 在队列中插入字符串 '-'
6 | q.put('100') # 在队列中插入字符串 '100'
7 | for i in range(4): # 从队列中取数据,取出次数为4次,引发 queue.Empty 异常
8 | print(q.get(block=False))
9 | except queue.Empty:
10 | print('queue.Empty')
--------------------------------------------------------------------------------
/day-029/queue.Full.py:
--------------------------------------------------------------------------------
1 | import queue
2 | try:
3 | q = queue.Queue(3) # 设置队列上限为3
4 | q.put('python') # 在队列中插入字符串 'python'
5 | q.put('-') # 在队列中插入字符串 '-'
6 | q.put('100') # 在队列中插入字符串 '100'
7 | q.put('stay hungry, stay foolish', block=False) # 队列已满,继续往队列中放入数据,引发 queue.Full 异常
8 | except queue.Full:
9 | print('queue.Full')
--------------------------------------------------------------------------------
/day-029/queue.LifoQueue.py:
--------------------------------------------------------------------------------
1 | import queue
2 | q = queue.LifoQueue() # 创建 LifoQueue 队列
3 | for i in range(3):
4 | q.put(i) # 在队列中依次插入0、1、2元素
5 | for i in range(3):
6 | print(q.get()) # 依次从队列中取出插入的元素,数据元素输出顺序为2、1、0
--------------------------------------------------------------------------------
/day-029/queue.PriorityQueue.py:
--------------------------------------------------------------------------------
1 | import queue
2 | q = queue.PriorityQueue() # 创建 PriorityQueue 队列
3 | data1 = (1, 'python')
4 | data2 = (2, '-')
5 | data3 = (3, '100')
6 | style = (data2, data3, data1)
7 | for i in style:
8 | q.put(i) # 在队列中依次插入元素 data2、data3、data1
9 | for i in range(3):
10 | print(q.get()) # 依次从队列中取出插入的元素,数据元素输出顺序为 data1、data2、data3
--------------------------------------------------------------------------------
/day-029/queue.Queue.py:
--------------------------------------------------------------------------------
1 | import queue
2 | q = queue.Queue() # 创建 Queue 队列
3 | for i in range(3):
4 | q.put(i) # 在队列中依次插入0、1、2元素
5 | for i in range(3):
6 | print(q.get()) # 依次从队列中取出插入的元素,数据元素输出顺序为0、1、2
7 |
--------------------------------------------------------------------------------
/day-029/queue.SimpleQueue.py:
--------------------------------------------------------------------------------
1 | import queue
2 | q = queue.SimpleQueue() # 创建 SimpleQueue 队列
3 | for i in range(3):
4 | q.put(i) # 在队列中依次插入0、1、2元素
5 | for i in range(3):
6 | print(q.get()) # 依次从队列中取出插入的元素,数据元素输出顺序为0、1、2
--------------------------------------------------------------------------------
/day-030/ChainMap_demo.py:
--------------------------------------------------------------------------------
1 | from collections import ChainMap
2 |
3 | user1 = {"name":"admin", "age":"20"}
4 | user2 = {"name":"root", "weight": 65}
5 | users = ChainMap(user1, user2)
6 | print(users.maps)
7 |
8 | users.maps[0]["name"] = "tiger"
9 | print(users.maps)
10 |
11 | for key, value in users.items():
12 | print(key, value)
--------------------------------------------------------------------------------
/day-030/Counter_demo.py:
--------------------------------------------------------------------------------
1 | from collections import Counter
2 |
3 | animals = ["cat", "dog", "cat", "bird", "horse", "tiger", "horse", "cat"]
4 | animals_counter = Counter(animals)
5 | print(animals_counter)
6 | print(animals_counter.most_common(2))
--------------------------------------------------------------------------------
/day-030/OrderedDict_demo.py:
--------------------------------------------------------------------------------
1 | from collections import OrderedDict
2 |
3 | user = OrderedDict()
4 | user["name"] = "admin"
5 | user["age"] = 23
6 | user["weight"] = 65
7 | print(user)
8 |
9 | user.move_to_end("name")
10 | print(user)
11 |
12 | user.move_to_end("name", last = False)
13 | print(user)
--------------------------------------------------------------------------------
/day-030/defaultdict_demo.py:
--------------------------------------------------------------------------------
1 | from collections import defaultdict
2 |
3 | default_dict = defaultdict(int)
4 | default_dict["x"] = 10
5 |
6 | print(default_dict["x"])
7 | print(default_dict["y"])
8 |
9 | def getUserInfo():
10 | return {
11 | "name" : "",
12 | "age" : 0
13 | }
14 |
15 | default_dict = defaultdict(getUserInfo)
16 | admin = default_dict["admin"]
17 | print(admin)
18 | admin["age"] = 34
19 | print(admin)
--------------------------------------------------------------------------------
/day-030/deque_demo.py:
--------------------------------------------------------------------------------
1 | from collections import deque
2 | q = deque([1, 2, 3])
3 | q.append('4')
4 | q.appendleft('0')
5 | print(q)
6 |
7 | print(q.popleft())
8 |
--------------------------------------------------------------------------------
/day-030/namedtuple_demo.py:
--------------------------------------------------------------------------------
1 | from collections import namedtuple
2 | User = namedtuple("User",["name", "age", "weight"])
3 | user = User("admin", 20, 60)
4 | name, age, weight = user
5 |
6 | print(user[0])
7 | print(name, age, weight)
8 | print(user.name, user.age, user.weight)
9 |
10 | # 常用方法
11 |
12 | # 将序列直接转换为新的 tuple 对象
13 | user = ["root", 32, 65]
14 | user = User._make(user)
15 | print(user) # User(name='root', age=32, weight=65)
16 |
17 | # 返回一个 dict
18 | user = User("admin", 20, 60)
19 | print(user._asdict()) # OrderedDict([('name', 'admin'), ('age', 20), ('weight', 60)])
--------------------------------------------------------------------------------
/day-032/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-032/__init__.py
--------------------------------------------------------------------------------
/day-032/advance-operationLog/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-032/advance-operationLog/__init__.py
--------------------------------------------------------------------------------
/day-032/advance-operationLog/operation_log.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 | sh = logging.StreamHandler(stream=None)
--------------------------------------------------------------------------------
/day-032/configLogging/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-032/configLogging/__init__.py
--------------------------------------------------------------------------------
/day-032/configLogging/config_logging.py:
--------------------------------------------------------------------------------
1 | import logging
2 | # create logger
3 | logger = logging.getLogger('simple_example')
4 | logger.setLevel(logging.DEBUG)
5 |
6 | # create console handler and set level to debug
7 | ch = logging.StreamHandler()
8 | ch.setLevel(logging.DEBUG)
9 |
10 | # create formatter
11 | formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
12 |
13 | # add formatter to ch
14 | ch.setFormatter(formatter)
15 |
16 | # add ch to logger
17 | logger.addHandler(ch)
18 |
19 | # 'application' code
20 | logger.debug('debug message')
21 | logger.info('info message')
22 | logger.warning('warn message')
23 | logger.error('error message')
24 | logger.critical('critical message')
--------------------------------------------------------------------------------
/day-032/configLogging/logging.conf:
--------------------------------------------------------------------------------
1 | [loggers]
2 | keys=root,simpleExample
3 |
4 | [handlers]
5 | keys=consoleHandler
6 |
7 | [formatters]
8 | keys=simpleFormatter
9 |
10 | [logger_root]
11 | level=DEBUG
12 | handlers=consoleHandler
13 |
14 | [logger_simpleExample]
15 | level=DEBUG
16 | handlers=consoleHandler
17 | qualname=simpleExample
18 | propagate=0
19 |
20 | [handler_consoleHandler]
21 | class=StreamHandler
22 | level=DEBUG
23 | formatter=simpleFormatter
24 | args=(sys.stdout,)
25 |
26 | [formatter_simpleFormatter]
27 | format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
28 | datefmt=
--------------------------------------------------------------------------------
/day-032/configLogging/recorder.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import logging.config
3 |
4 | logging.config.fileConfig('logging.conf')
5 |
6 | # create logger
7 | logger = logging.getLogger('simpleExample')
8 |
9 | # 'application' code
10 | logger.debug('debug message')
11 | logger.info('info message')
12 | logger.warning('warn message')
13 | logger.error('error message')
14 | logger.critical('critical message')
--------------------------------------------------------------------------------
/day-032/message2file.py:
--------------------------------------------------------------------------------
1 |
2 | import logging
3 | # 日志信息记录到指定的文件中
4 | logging.basicConfig(filename='F:/example.log', level=logging.DEBUG)
5 | logging.debug('This message should go to the log file')
6 | logging.info('So should this')
7 | logging.warning('And this, too')
--------------------------------------------------------------------------------
/day-032/message_format.py:
--------------------------------------------------------------------------------
1 | import logging
2 | # 更改显示消息的格式
3 | logging.basicConfig(format='%(levelname)s:%(message)s',level=logging.DEBUG)
4 | logging.debug('Python message format Debug')
5 | logging.info('Python message format Info')
6 | logging.warning('Python message format Warning')
--------------------------------------------------------------------------------
/day-032/multi-module/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-032/multi-module/__init__.py
--------------------------------------------------------------------------------
/day-032/multi-module/__pycache__/mylib.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-032/multi-module/__pycache__/mylib.cpython-36.pyc
--------------------------------------------------------------------------------
/day-032/multi-module/myapp.log:
--------------------------------------------------------------------------------
1 |
2 | INFO:root:Started
3 | INFO:root:Doing something
4 | INFO:root:Finished
5 |
--------------------------------------------------------------------------------
/day-032/multi-module/myapp.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import mylib
3 | def main():
4 | logging.basicConfig(filename='myapp.log',level=logging.DEBUG)
5 | logging.info('Started')
6 | mylib.do_something()
7 | logging.info('Finished')
8 |
9 | if __name__ == '__main__':
10 | main()
--------------------------------------------------------------------------------
/day-032/multi-module/mylib.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 | def do_something():
4 | logging.info('Doing something')
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/day-032/python_logging.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 | # 打印日志级别
4 | def test():
5 | logging.basicConfig(level=logging.DEBUG)
6 | logging.debug('Python debug')
7 | logging.info('Python info')
8 | logging.warning('Python warning')
9 | logging.error('Python Error')
10 | logging.critical('Python critical')
11 |
12 | test()
13 |
14 | # 记录可变数据
15 | logging.warning('%s before you %s', 'Look', 'leap!')
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/day-032/show_logtime.py:
--------------------------------------------------------------------------------
1 | import logging
2 | # 显示消息时间
3 | logging.basicConfig(format='%(asctime)s %(message)s')
4 | logging.warning('is when this event was logged.')
5 |
6 | logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
7 | logging.warning('is when this event was logged.')
--------------------------------------------------------------------------------
/day-033/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-033/__init__.py
--------------------------------------------------------------------------------
/day-033/enum_access.py:
--------------------------------------------------------------------------------
1 | from enum import Enum
2 |
3 | # 创建
4 | class HttpStatus(Enum):
5 | OK = 200
6 | BAD_REQUEST = 400
7 | FORBIDDEN = 403
8 | NOT_FOUND = 404
9 | REQUEST_TIMEOUT = 408
10 | SERVICE_UNAVAILABLE = 500
11 |
12 | # value 访问使用元组()
13 | print(HttpStatus(200)) # HttpStatus.OK
14 | # name 访问使用list[]
15 | print(HttpStatus['OK']) # HttpStatus.OK
16 |
17 | # 赋值给 enum对象
18 | number = HttpStatus.OK
19 | print(number) # HttpStatus.OK
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/day-033/enum_compare.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from enum import Enum, IntEnum
3 |
4 | class TestEnum(unittest.TestCase):
5 | class Season(IntEnum):
6 | SPRING = 1
7 | SUMMER = 2
8 | AUTUMN = 3
9 | WINTER = 4
10 |
11 | def test_comparisons(self):
12 | season = self.Season
13 |
14 | self.assertEqual(season.SPRING, 1)
15 |
16 | class Part(Enum):
17 | SPRING = 1
18 | CLIP = 2
19 | BARREL = 3
20 |
21 | self.assertNotEqual(Part.SPRING, 1)
22 | self.assertNotEqual(Part.SPRING, season.SPRING)
23 |
24 | TestEnum().test_comparisons()
25 |
--------------------------------------------------------------------------------
/day-033/enum_iterate.py:
--------------------------------------------------------------------------------
1 | from enum import Enum
2 |
3 | # 创建
4 | class HttpStatus(Enum):
5 | OK = 200
6 | BAD_REQUEST = 400
7 | FORBIDDEN = 403
8 | NOT_FOUND = 404
9 | REQUEST_TIMEOUT = 408
10 | SERVICE_UNAVAILABLE = 500
11 | OTHER = 200
12 |
13 | # 迭代
14 | for status in HttpStatus:
15 | print('{} : {}'.format(status.name, status.value))
16 |
17 | print('\n')
18 |
19 | # 使用
20 | # print([name for name, member in HttpStatus.__members__.items() if member.name != name])
21 | for name, member in HttpStatus.__members__.items():
22 | print('{} : {}'.format(name, member))
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/day-033/enum_unique.py:
--------------------------------------------------------------------------------
1 | from enum import Enum, unique
2 |
3 | # 创建
4 | @unique
5 | class HttpStatus(Enum):
6 | OK = 200
7 | BAD_REQUEST = 400
8 | FORBIDDEN = 403
9 | NOT_FOUND = 404
10 | REQUEST_TIMEOUT = 408
11 | SERVICE_UNAVAILABLE = 500
12 | OTHER = 200
13 |
14 | # ValueError: duplicate values found in : OTHER -> OK
15 | print(HttpStatus)
16 |
17 |
--------------------------------------------------------------------------------
/day-034/json-load&loads.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | #把json串变成python的数据类型
3 | import json
4 | #打开‘users.json’的json文件
5 | f =open('users.json','r',encoding='utf-8')
6 | #读文件
7 | res=f.read()
8 | print(json.loads(res))
9 |
10 |
11 | #把json串变成python的数据类型:字典,传一个文件对象,不需要再单独读文件
12 | import json
13 | #打开文件
14 | f =open('users.json','r',encoding='utf-8')
15 | print(json.load(f))
--------------------------------------------------------------------------------
/day-034/pickle.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | # dumps功能
3 | import pickle
4 | data = ['A', 'B', 'C','D']
5 | datastr = pickle.dumps(data)
6 | print(datastr)
7 |
8 |
9 | # dump功能
10 | with open('test.txt', 'wb') as f:
11 | pickle.dump(data, f)
12 | print('写入成功')
13 |
14 |
15 | # loads功能
16 | msg = pickle.loads(datastr)
17 | print(msg)
18 |
19 |
20 | # load功能
21 | with open('test.txt', 'rb') as f:
22 | data = pickle.load(f)
23 | print(data)
--------------------------------------------------------------------------------
/day-035/1.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 | currentPath = Path.cwd()
3 | homePath = Path.home()
4 | print("文件当前所在目录:%s\n用户主目录:%s" %(currentPath, homePath))
--------------------------------------------------------------------------------
/day-035/2.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 | currentPath = Path.cwd()
3 | newPath = currentPath / 'python-100'
4 | print("新目录为:%s" %(newPath))
--------------------------------------------------------------------------------
/day-035/3.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 | currentPath = Path.cwd()
3 | makePath = currentPath / 'python-100'
4 | makePath.mkdir()
5 | print("创建的目录为:%s" %(nmakePath))
6 |
7 |
8 | from pathlib import Path
9 | currentPath = Path.cwd()
10 | delPath = currentPath / 'python-100'
11 | delPath.rmdir()
12 | print("删除的目录为:%s" %(delPath))
--------------------------------------------------------------------------------
/day-035/4.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 | currentPath = Path.cwd()
3 | mkPath = currentPath / 'python-100.txt'
4 | with mkPath.open('w') as f: # 创建并以 "w" 格式打开 python-100.txt 文件。
5 | f.write('python-100') # 写入 python-100 字符串。
6 | f = open(mkPath, 'r')
7 | print("读取的文件内容为:%s" % f.read())
8 | f.close()
9 |
10 |
11 | from pathlib import Path
12 | currentPath = Path.cwd()
13 | mkPathText = currentPath / 'python-100-text.txt'
14 | mkPathText.write_text('python-100')
15 | print("读取的文件内容为:%s" % mkPathText.read_text())
16 |
17 | str2byte = bytes('python-100', encoding = 'utf-8')
18 | mkPathByte = currentPath / 'python-100-byte.txt'
19 | mkPathByte.write_bytes(str2byte)
20 | print("读取的文件内容为:%s" % mkPathByte.read_bytes())
--------------------------------------------------------------------------------
/day-035/5.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 | txtPath = Path('python-100.txt')
3 | nowPath = txtPath.resolve()
4 | print("文件的完整路径为:%s" % nowPath)
5 | print("文件完整名称为(文件名+后缀名):%s" % nowPath.name)
6 | print("文件名为:%s" % nowPath.stem)
7 | print("文件后缀名为:%s" % nowPath.suffix)
8 | print("文件所在的文件夹名为:%s" % nowPath.parent)
9 | print("文件所在的盘符为:%s" % nowPath.anchor)
--------------------------------------------------------------------------------
/day-035/7.py:
--------------------------------------------------------------------------------
1 | # 使用 Path.iterdir() 获取当前文件下的所有文件,并根据后缀名统计其个数。
2 | import pathlib
3 | from collections import Counter
4 | currentPath = pathlib.Path.cwd()
5 | gen = (i.suffix for i in currentPath.iterdir())
6 | print(Counter(gen))
7 |
8 |
9 |
10 | import pathlib
11 | from collections import Counter
12 | currentPath = pathlib.Path.cwd()
13 | gen = (i.suffix for i in currentPath.glob('*.txt')) # 获取当前文件下的所有 txt 文件,并统计其个数。
14 | print(Counter(gen))
15 | gen = (i.suffix for i in currentPath.rglob('*.txt')) # 获取目录中子文件夹下的所有 txt 文件,并统计其个数。
16 | print(Counter(gen))
--------------------------------------------------------------------------------
/day-036/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-036/__init__.py
--------------------------------------------------------------------------------
/day-037/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-037/__init__.py
--------------------------------------------------------------------------------
/day-038/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-038/__init__.py
--------------------------------------------------------------------------------
/day-039/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-039/.DS_Store
--------------------------------------------------------------------------------
/day-039/itertools-chain-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | x = itertools.chain("abc", "xyz")
3 | print(list(x))
--------------------------------------------------------------------------------
/day-039/itertools-combinations-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | print(list(itertools.combinations("abc", r=2)))
--------------------------------------------------------------------------------
/day-039/itertools-combinations_with_replacement-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | print(list(itertools.combinations_with_replacement("abc", r=2)))
--------------------------------------------------------------------------------
/day-039/itertools-compress-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | data = [81, 82, 84, 76, 64, 78]
3 | tf = [1,1,0,1,1,0]
4 | print(list(itertools.compress(data, tf)))
--------------------------------------------------------------------------------
/day-039/itertools-count-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | x = itertools.count(1,2)
3 | for k in x:
4 | print(k, end=", ")
5 |
--------------------------------------------------------------------------------
/day-039/itertools-cycle-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | x = itertools.cycle("XYZ")
3 | for k in x:
4 | print(k, end = ", ")
--------------------------------------------------------------------------------
/day-039/itertools-dropwhile-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | x = itertools.dropwhile(lambda x: x < 5, [1,3,5,7,4,2,1])
3 | print(list(x))
--------------------------------------------------------------------------------
/day-039/itertools-filterfalse-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | x = itertools.filterfalse(lambda x: x < 5, [1,3,5,7,4,2,1])
3 | print(list(x))
--------------------------------------------------------------------------------
/day-039/itertools-groupby-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | def sortBy(score):
3 | if score > 80:
4 | return "A"
5 | elif score >= 60:
6 | return "B"
7 | else:
8 | return "C"
9 |
10 | scores = [81, 82, 84, 76, 64, 78, 59, 44, 55, 89]
11 | #scores = sorted(scores, key=sortBy) # 将此行代码注释打开即可得到合理的结果
12 | for m, n in itertools.groupby(scores, key=sortBy):
13 | print(m, list(n))
14 |
--------------------------------------------------------------------------------
/day-039/itertools-islice-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | print(list(itertools.islice('123456789', 2)))
3 | print(list(itertools.islice('123456789', 2, 4)))
4 | print(list(itertools.islice('123456789', 2, None)))
5 | print(list(itertools.islice('123456789', 0, None, 2)))
--------------------------------------------------------------------------------
/day-039/itertools-permutations-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | print(list(itertools.permutations("aba", r=2)))
--------------------------------------------------------------------------------
/day-039/itertools-product-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | print(list(itertools.product("ab", "12")))
3 | print(list(itertools.product("ab", "ab")))
4 | print(list(itertools.product("ab", repeat=2)))
--------------------------------------------------------------------------------
/day-039/itertools-repeat-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | #x = itertools.repeat("XYZ")
3 | x = itertools.repeat("XYZ", 3)
4 | for k in x:
5 | print(k, end = ", ")
--------------------------------------------------------------------------------
/day-039/itertools-starmap-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | print(list(itertools.starmap(pow,[(2,10), (3,3)])))
--------------------------------------------------------------------------------
/day-039/itertools-takewhile-demo.py:
--------------------------------------------------------------------------------
1 | import itertools
2 | x = itertools.takewhile(lambda x: x < 5, [1,3,5,7,4,2,1])
3 | print(list(x))
--------------------------------------------------------------------------------
/day-040/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-040/.DS_Store
--------------------------------------------------------------------------------
/day-042/paramiko_cmd.py:
--------------------------------------------------------------------------------
1 | import paramiko
2 |
3 |
4 | ssh = paramiko.SSHClient()
5 | ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
6 | ssh.connect("IP","端口号","用户名", "密码")
7 | # # 执行命令
8 | catin, catout,caterr = ssh.exec_command('cd data;cat paramiko.txt')
9 | # # 结果放到stdout中,如果有错误将放到stderr中
10 | print(catout.read().decode('utf-8'))
11 | ssh.close()
12 |
--------------------------------------------------------------------------------
/day-042/paramiko_file.py:
--------------------------------------------------------------------------------
1 | import paramiko
2 |
3 | transport = paramiko.Transport(("IP", 端口号))
4 | transport.connect(username = "用户名", password = "密码")
5 | sftp = paramiko.SFTPClient.from_transport(transport)
6 | # 下载文件
7 | sftp.get("远程服务器文件地址",'本地文件名',print("上传完成"))
8 | # 上传文件
9 | sftp.put('本地文件地址','远程服务器文件地址')
10 | # 关闭连接
11 | transport.close();
12 |
--------------------------------------------------------------------------------
/day-042/paramiko_searchFile.py:
--------------------------------------------------------------------------------
1 | import paramiko
2 |
3 |
4 | try:
5 | client = paramiko.SSHClient()
6 | client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
7 | client.connect("IP","端口号","用户名", "密码", timeout=5)
8 | sftp = client.open_sftp()
9 | for fileName in sftp.listdir("/root/data"):
10 | if fileName.endswith(".txt"):
11 | print(fileName)
12 | except:
13 | print('文件没有找到!')
14 | finally:
15 | client.close()
16 |
--------------------------------------------------------------------------------
/day-043/filecmp&difflib.py:
--------------------------------------------------------------------------------
1 | #新建两个文件f1 和 f2
2 | #f1存储的数据是1,2,3
3 | #f2存储的数据是4,5,6
4 | import filecmp
5 | print(filecmp.cmp("f1","f1"))
6 | print(filecmp.cmp("f1","f2"))
7 |
8 |
9 | import difflib
10 | from pprint import pprint
11 |
12 | a = 'pythonclub.org is wonderful'
13 | b = 'Pythonclub.org also wonderful'
14 | s = difflib.SequenceMatcher(None, a, b)
15 |
16 | print ("s.get_matching_blocks():")
17 | pprint(s.get_matching_blocks())
18 | print ("s.get_opcodes():")
19 | for tag, i1, i2, j1, j2 in s.get_opcodes():
20 | print ("%7s a[%d:%d] (%s) b[%d:%d] (%s)" % (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2]))
21 |
22 |
--------------------------------------------------------------------------------
/day-044/flaskbootstrap.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, render_template
2 | from flask_bootstrap import Bootstrap
3 |
4 |
5 | app = Flask(__name__)
6 |
7 | bootstrap = Bootstrap(app)
8 | app.config['BOOTSTRAP_SERVE_LOCAL'] = True
9 |
10 |
11 | @app.route('/')
12 | def index():
13 | return render_template('index.html')
14 |
15 | @app.route('/user')
16 | def user():
17 | return render_template('user.html')
18 |
19 | @app.route('/post')
20 | def post():
21 | return render_template('post.html')
22 |
23 | if __name__ == '__main__':
24 | app.run(debug=True)
--------------------------------------------------------------------------------
/day-044/static/css/style.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-044/static/css/style.css
--------------------------------------------------------------------------------
/day-044/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% from 'bootstrap/nav.html' import render_breadcrumb_item %}
4 | {% from 'bootstrap/utils.html' import render_static %}
5 |
6 | {{ render_static('css', 'style.css') }}
7 |
8 | {% block content %}
9 | 面包屑
10 |
11 |
12 | {{ render_breadcrumb_item('index', '首页') }}
13 | {{ render_breadcrumb_item('user', '用户') }}
14 | {{ render_breadcrumb_item('post', '文章') }}
15 |
16 |
17 | Hello Flask Bootstrap
18 | {% endblock %}
19 |
--------------------------------------------------------------------------------
/day-044/templates/post.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% from 'bootstrap/nav.html' import render_breadcrumb_item %}
3 | {% block content %}
4 | 面包屑
5 |
6 |
7 | {{ render_breadcrumb_item('index', '首页') }}
8 | {{ render_breadcrumb_item('user', '用户') }}
9 | {{ render_breadcrumb_item('post', '文章') }}
10 |
11 |
12 |
13 | Welcome to Post page!
14 | {% endblock %}
--------------------------------------------------------------------------------
/day-044/templates/user.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% from 'bootstrap/nav.html' import render_breadcrumb_item %}
3 | {% block content %}
4 | 面包屑
5 |
6 |
7 | {{ render_breadcrumb_item('index', '首页') }}
8 | {{ render_breadcrumb_item('user', '用户') }}
9 | {{ render_breadcrumb_item('post', '文章') }}
10 |
11 |
12 |
13 | Welcome to User page!
14 |
15 | {% endblock %}
--------------------------------------------------------------------------------
/day-045/templates/bootstrap.html:
--------------------------------------------------------------------------------
1 | {% from 'bootstrap/form.html' import render_form, render_form_row, render_field %}
2 | {{ bootstrap.load_css() }}
3 | render_form
4 | {{ render_form(form) }}
5 |
6 | render_form_row
7 |
12 |
13 | render_field
14 |
19 |
20 |
--------------------------------------------------------------------------------
/day-045/templates/submit.html:
--------------------------------------------------------------------------------
1 | {% macro render_field(field) %}
2 | {{ field.label }}:
3 | {{ field(**kwargs)|safe }}
4 | {% if field.errors %}
5 |
6 | {% for error in field.errors %}
7 | {{ error }}
8 | {% endfor %}
9 |
10 | {% endif %}
11 |
12 | {% endmacro %}
13 |
14 |
--------------------------------------------------------------------------------
/day-045/templates/upload.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-046/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-046/.DS_Store
--------------------------------------------------------------------------------
/day-046/templates/createprofile.html:
--------------------------------------------------------------------------------
1 | {% macro render_field(field) %}
2 | {{ field.label }}:
3 | {{ field(**kwargs)|safe }}
4 | {% if field.errors %}
5 |
6 | {% for error in field.errors %}
7 | {{ error }}
8 | {% endfor %}
9 |
10 | {% endif %}
11 |
12 | {% endmacro %}
13 |
14 |
--------------------------------------------------------------------------------
/day-046/templates/profile.html:
--------------------------------------------------------------------------------
1 | {{ profile.name }}'s Info
2 | Name:
3 | {{ profile.name }}
4 | Birthday:
5 | {{ profile.birthday }}
6 | About:
7 | {{ profile.about }}
--------------------------------------------------------------------------------
/day-048/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-048/__init__.py
--------------------------------------------------------------------------------
/day-048/compute_multi_process.py:
--------------------------------------------------------------------------------
1 | # 计算密集型任务-多进程
2 | from multiprocessing import Process
3 | import os,time
4 |
5 | def task():
6 | ret = 0
7 | for i in range(100000000):
8 | ret *= i
9 | if __name__ == '__main__':
10 | arr = []
11 | print('本机为',os.cpu_count(),'核 CPU')
12 | start = time.time()
13 | for i in range(5):
14 | p = Process(target=task)
15 | arr.append(p)
16 | p.start()
17 | for p in arr:
18 | p.join()
19 | stop = time.time()
20 | print('计算密集型任务,多进程耗时 %s' % (stop - start))
--------------------------------------------------------------------------------
/day-048/compute_multi_thread.py:
--------------------------------------------------------------------------------
1 | # 计算密集型任务-多线程
2 | from threading import Thread
3 | import os,time
4 |
5 | def task():
6 | ret = 0
7 | for i in range(100000000):
8 | ret *= i
9 | if __name__ == '__main__':
10 | arr = []
11 | print('本机为',os.cpu_count(),'核 CPU')
12 | start = time.time()
13 | for i in range(5):
14 | p = Thread(target=task)
15 | arr.append(p)
16 | p.start()
17 | for p in arr:
18 | p.join()
19 | stop = time.time()
20 | print('多线程耗时 %s' % (stop - start))
--------------------------------------------------------------------------------
/day-048/compute_single_thread.py:
--------------------------------------------------------------------------------
1 | # 计算密集型任务-单线程
2 | from threading import Thread
3 | import os,time
4 |
5 | def task():
6 | ret = 0
7 | for i in range(100000000):
8 | ret *= i
9 | if __name__ == '__main__':
10 | print('本机为',os.cpu_count(),'核 CPU')
11 | start = time.time()
12 | for i in range(5):
13 | task()
14 | stop = time.time()
15 | print('单线程耗时 %s' % (stop - start))
--------------------------------------------------------------------------------
/day-048/io_multi_process.py:
--------------------------------------------------------------------------------
1 | # I/O 密集型任务-多进程
2 | from multiprocessing import Process
3 | import os,time
4 |
5 | def task():
6 | f = open('tmp.txt','w')
7 | if __name__ == '__main__':
8 | arr = []
9 | print('本机为',os.cpu_count(),'核 CPU')
10 | start = time.time()
11 | for i in range(500):
12 | p = Process(target=task)
13 | arr.append(p)
14 | p.start()
15 | for p in arr:
16 | p.join()
17 | stop = time.time()
18 | print('I/O 密集型任务,多进程耗时 %s' % (stop - start))
--------------------------------------------------------------------------------
/day-048/io_multi_thread.py:
--------------------------------------------------------------------------------
1 | # I/O 密集型任务-多线程
2 | from threading import Thread
3 | import os,time
4 |
5 | def task():
6 | f = open('tmp.txt','w')
7 | if __name__ == '__main__':
8 | arr = []
9 | print('本机为',os.cpu_count(),'核 CPU')
10 | start = time.time()
11 | for i in range(500):
12 | p = Thread(target=task)
13 | arr.append(p)
14 | p.start()
15 | for p in arr:
16 | p.join()
17 | stop = time.time()
18 | print('I/O 密集型任务,多线程耗时 %s' % (stop - start))
--------------------------------------------------------------------------------
/day-048/io_single_thread.py:
--------------------------------------------------------------------------------
1 | # I/O 密集型任务-单线程
2 | from threading import Thread
3 | import os,time
4 |
5 | def task():
6 | f = open('tmp.txt','w')
7 | if __name__ == '__main__':
8 | arr = []
9 | print('本机为',os.cpu_count(),'核 CPU')
10 | start = time.time()
11 | for i in range(500):
12 | task()
13 | stop = time.time()
14 | print('I/O 密集型任务,单线程耗时 %s' % (stop - start))
--------------------------------------------------------------------------------
/day-048/tmp.txt:
--------------------------------------------------------------------------------
1 | In CPython, the global interpreter lock, or GIL, is a mutex that prevents multiple native threads from executing
2 | Python bytecodes at once. This lock is necessary mainly because CPython’s memory management is not thread-safe.
3 | (However, since the GIL exists, other features have grown to depend on the guarantees that it enforces.)
4 |
--------------------------------------------------------------------------------
/day-049/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-049/__init__.py
--------------------------------------------------------------------------------
/day-049/daemon.py:
--------------------------------------------------------------------------------
1 | import threading
2 | def work(num):
3 | for i in range(num):
4 | print(threading.current_thread().name + " " + str(i))
5 | t = threading.Thread(target=work, args=(10,), name='守护线程')
6 | #t.daemon = True
7 | t.start()
8 | for i in range(10):
9 | pass
--------------------------------------------------------------------------------
/day-049/local.py:
--------------------------------------------------------------------------------
1 | import threading
2 | import time
3 |
4 | # 不使用 threading.local
5 | num = 0
6 | def work():
7 | global num
8 | for i in range(10):
9 | num += 1
10 | print(threading.current_thread().getName(), num)
11 | time.sleep(0.0001)
12 | for i in range(5):
13 | threading.Thread(target=work).start()
14 |
15 | # 使用 threading.local
16 | num = threading.local()
17 | def work():
18 | num.x = 0
19 | for i in range(10):
20 | num.x += 1
21 | print(threading.current_thread().getName(), num.x)
22 | time.sleep(0.0001)
23 | for i in range(5):
24 | threading.Thread(target=work).start()
--------------------------------------------------------------------------------
/day-049/timer.py:
--------------------------------------------------------------------------------
1 | from threading import Timer
2 | import time
3 | #定时器-单次执行
4 | # def work():
5 | # print("Hello Python")
6 | # # 5 秒后执行 work 方法
7 | # t = Timer(5, work)
8 | # t.start()
9 |
10 | #定时器-重复执行
11 | count = 0
12 | def work():
13 | print('当前时间:', time.strftime('%Y-%m-%d %H:%M:%S'))
14 | global t, count
15 | count += 1
16 | # 如果 count 小于 5,开始下一次调度
17 | if count < 5:
18 | t = Timer(1, work)
19 | t.start()
20 | # 指定 2 秒后执行 work 方法
21 | t = Timer(2, work)
22 | t.start()
--------------------------------------------------------------------------------
/day-050/producer_consumer_simple_version.py:
--------------------------------------------------------------------------------
1 | import threading
2 | import time
3 | import queue
4 |
5 | def consume(thread_name, q):
6 | while True:
7 | time.sleep(2)
8 | product = q.get()
9 | print("%s consume %s" % (thread_name, product))
10 |
11 | def produce(thread_name, q):
12 | for i in range(3):
13 | product = 'product-' + str(i)
14 | q.put(product)
15 | print("%s produce %s" % (thread_name, product))
16 | time.sleep(1)
17 |
18 |
19 | q = queue.Queue()
20 | p = threading.Thread(target=produce, args=("producer",q))
21 | c = threading.Thread(target=consume, args=("consumer",q))
22 |
23 | p.start()
24 | c.start()
25 |
26 | p.join()
--------------------------------------------------------------------------------
/day-051/queue_common_function_demo.py:
--------------------------------------------------------------------------------
1 | import queue
2 | q = queue.Queue()
3 | q.put(100)
4 | q.put(200)
5 | q.qsize() # 获取队列大小,此处结果为 2
6 |
7 |
8 | import queue
9 | q = queue.Queue(maxsize=1)
10 | q.empty() # 判断队列是否空,此处结果为 True
11 | q.full() # 判断队列是否满,此处结果为 False
12 | q.put(100)
13 | q.empty() # False
14 | q.full() # True
--------------------------------------------------------------------------------
/day-052/__pycache__/multiprocessing.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-052/__pycache__/multiprocessing.cpython-37.pyc
--------------------------------------------------------------------------------
/day-052/multiprocessing-lock.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | from multiprocessing import Process, Lock
3 | def f(l, i):
4 | l.acquire()
5 | try:
6 | print('this is', i)
7 | finally:
8 | l.release()
9 |
10 | if __name__ == '__main__':
11 | lock = Lock()
12 |
13 | for num in range(10):
14 | Process(target=f, args=(lock, num)).start()
--------------------------------------------------------------------------------
/day-052/multiprocessing-pipe.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | #Pipe管道
3 | from multiprocessing import Process, Pipe
4 | def f(conn):
5 | conn.send([11, None, 'lily'])
6 | conn.close()
7 |
8 | if __name__ == '__main__':
9 | conn1, conn2 = Pipe()
10 | p = Process(target=f, args=(conn2,))
11 | p.start()
12 | print(conn1.recv())
13 | p.join()
--------------------------------------------------------------------------------
/day-052/multiprocessing-queue.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | #Queue队列
3 | from multiprocessing import Process, Queue
4 | def f(q):
5 | q.put([11, None, 'lily'])
6 | if __name__ == '__main__':
7 | q = Queue()
8 | p = Process(target=f, args=(q,))
9 | p.start()
10 | print(q.get())
11 | p.join()
--------------------------------------------------------------------------------
/day-052/multiprocessingDemo.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | from multiprocessing import Process
3 | def f(name):
4 | print('hello', name)
5 | if __name__ == '__main__':
6 | p = Process(target=f, args=('world',))
7 | #启动进程
8 | p.start()
9 | #实现进程间的同步,等待所有进程退出
10 | p.join()
11 |
12 | #主子进程执行顺序
13 | from multiprocessing import Process
14 | import os
15 | import time
16 | def run():
17 | print("子进程开启")
18 | time.sleep(2)
19 | print("子进程结束")
20 |
21 | if __name__ == "__main__":
22 | print("主进程启动")
23 | p = Process(target=run)
24 | p.start()
25 | print("主进程结束")
26 |
27 |
28 |
--------------------------------------------------------------------------------
/day-052/queue_common_function_demo.py:
--------------------------------------------------------------------------------
1 | import queue
2 | q = queue.Queue()
3 | q.put(100)
4 | q.put(200)
5 | q.qsize() # 获取队列大小,此处结果为 2
6 |
7 |
8 | import queue
9 | q = queue.Queue(maxsize=1)
10 | q.empty() # 判断队列是否空,此处结果为 True
11 | q.full() # 判断队列是否满,此处结果为 False
12 | q.put(100)
13 | q.empty() # False
14 | q.full() # True
--------------------------------------------------------------------------------
/day-053/threadpool-demo.py:
--------------------------------------------------------------------------------
1 | import time
2 | import threadpool
3 | import threading
4 |
5 | def sayhello(name):
6 | print("%s say Hello to %s" % (threading.current_thread().getName(), name));
7 | time.sleep(1)
8 | return name
9 |
10 | def callback(request, result): # 回调函数,用于取回结果
11 | print("callback result = %s" % result)
12 |
13 | name_list =['admin','root','scott','tiger']
14 | start_time = time.time()
15 | pool = threadpool.ThreadPool(2) # 创建线程池
16 | requests = threadpool.makeRequests(sayhello, name_list, callback) # 创建任务
17 | [pool.putRequest(req) for req in requests] # 加入任务
18 | pool.wait()
19 | print('%s cost %d second' % (threading.current_thread().getName(), time.time()-start_time))
--------------------------------------------------------------------------------
/day-056/Example_HTTPError.py:
--------------------------------------------------------------------------------
1 | # 返回401未授权错误
2 | from urllib import request,error
3 | try:
4 | response=request.urlopen('http://pythonscraping.com/pages/auth/login.php')
5 | print(response.getcode())
6 | except error.HTTPError as e:
7 | print('1.错误原因:\n%s\n2.状态码:\n%s\n3.响应头信息:\n%s' %(e.reason, e.code, e.headers))
8 | except error.URLError as e:
9 | print(e.reason)
--------------------------------------------------------------------------------
/day-056/Example_RobotFileParser.py:
--------------------------------------------------------------------------------
1 | # 使用两种爬虫代理分别查看是否可以对 'http://www.baidu.com' 网站进行爬取
2 | from urllib.robotparser import RobotFileParser
3 | rp = RobotFileParser()
4 | rp.set_url("http://www.baidu.com/robots.txt")
5 | rp.read()
6 | print(rp.can_fetch('Baiduspider', 'http://www.baidu.com'))
7 | print(rp.can_fetch('*', 'http://www.baidu.com'))
--------------------------------------------------------------------------------
/day-056/Example_URLError.py:
--------------------------------------------------------------------------------
1 | # 在请求连接时候捕获网址错误引发的异常
2 | from urllib import request, error
3 | try:
4 | response = request.urlopen('https://www,baidu,com')
5 | except error.URLError as e:
6 | print(e.reason)
--------------------------------------------------------------------------------
/day-056/Example_quote.py:
--------------------------------------------------------------------------------
1 | # 采用 quote 对 url 中的汉字进行编码,输出编码后的结果
2 | import urllib
3 | url = 'http://www.baidu.com/爬虫'
4 | result = urllib.parse.quote(url)
5 | print(result)
6 | url = 'http://www.baidu.com/+爬虫'
7 | result = urllib.parse.quote(url, '+') # 更改 safe 参数
8 | print(result)
--------------------------------------------------------------------------------
/day-056/Example_unquote.py:
--------------------------------------------------------------------------------
1 | # 解码经过 quote 函数处理后的 url,输出解码后的结果。
2 | import urllib
3 | url = 'http://www.baidu.com/爬虫'
4 | result = urllib.parse.quote(url)
5 | print(result)
6 | result = urllib.parse.unquote(url)
7 | print(result)
--------------------------------------------------------------------------------
/day-056/Example_urlencode.py:
--------------------------------------------------------------------------------
1 | # 创建 GET 请求
2 | import urllib
3 | params = {'username':'xxx','password':'123'}
4 | base_url='http://www.baidu.com'
5 | url=base_url + '?' + urllib.parse.urlencode(params)
6 | print(url)
7 | params = {'username':['xxx', 'yyy'], 'password':'123'} # username 键对应多个值
8 | base_url='http://www.baidu.com'
9 | url=base_url + '?' + urllib.parse.urlencode(params) # doseq 设置为 False,会解析成乱码
10 | print(url)
11 | url=base_url + '?' + urllib.parse.urlencode(params, True) # doseq 设置为 True
12 | print(url)
--------------------------------------------------------------------------------
/day-056/Example_urljoin.py:
--------------------------------------------------------------------------------
1 | # 基于 url 对 base_url 进行重新组合,并输出组合结果。
2 | import urllib
3 | base_url = 'http://www.baidu.com'
4 | url = 'https://www.google.com/urllib.parse.html;python?kw=urllib.parse#module-urllib'
5 | result = urllib.parse.urljoin(base_url,url,False)
6 | print(result)
--------------------------------------------------------------------------------
/day-056/Example_urlparse.py:
--------------------------------------------------------------------------------
1 | # 解析并输出 url 中每个字段的字符串
2 | import urllib
3 | url = 'http://www.baidu.com/urllib.parse.html;python?kw=urllib.parse#module-urllib'
4 | result = urllib.parse.urlparse(url)
5 | print(result)
6 | print(result.scheme, result.netloc, result.path, result.params, result.query, result.fragment, sep = '\n')
--------------------------------------------------------------------------------
/day-056/Example_urlsplit.py:
--------------------------------------------------------------------------------
1 | # 解析并输出 url 中每个字段的字符串,params 会合并到 path 中。
2 | import urllib
3 | url = 'http://www.baidu.com/urllib.parse.html;python?kw=urllib.parse#modul-urllib'
4 | result = urllib.parse.urlsplit(url)
5 | print(result)
6 | print(result.scheme, result.netloc, result.path, result.query, result.fragment, sep = '\n')
--------------------------------------------------------------------------------
/day-056/Example_urlunparse.py:
--------------------------------------------------------------------------------
1 | import urllib
2 | dataList = ['http', 'www.baidu.com', '/urllib.parse.html', 'python', 'kw=urllib.parse', 'modul-urllib'] # 六个字符串都必须填写,否则会出现 ValueError 错误,如果某一字符串不存在则填入空字符
3 | dataTuple = ('http', 'www.baidu.com', '/urllib.parse.html', '', 'kw=urllib.parse', 'modul-urllib') # 六个字符串都必须填写,否则会出现 ValueError 错误,如果某一字符串不存在则填入空字符
4 | urlList = urllib.parse.urlunparse(dataList)
5 | urlTuple = urllib.parse.urlunparse(dataTuple)
6 | print('1.urlList:%s\n2.urlTuple:%s' % (urlList, urlTuple))
--------------------------------------------------------------------------------
/day-056/Example_urlunsplit.py:
--------------------------------------------------------------------------------
1 | # 通过 data 列表或元组构造一个 url 并输出
2 | import urllib
3 | dataList = ['http', 'www.baidu.com', '/urllib.parse.html;python', 'kw=urllib.parse', 'modul-urllib'] # 五个字符串都必须填写,否则会出现 ValueError 错误,如果某一字符串不存在则填入空字符
4 | dataTuple = ('http', 'www.baidu.com', '/urllib.parse.html;python', 'kw=urllib.parse', 'modul-urllib') # 五个字符串都必须填写,否则会出现 ValueError 错误,如果某一字符串不存在则填入空字符
5 | urlList = urllib.parse.urlunsplit(dataList)
6 | urlTuple = urllib.parse.urlunsplit(dataTuple)
7 | print('1.urlList:%s\n2.urlTuple:%s' % (urlList, urlTuple))
--------------------------------------------------------------------------------
/day-057/templates/index.html:
--------------------------------------------------------------------------------
1 | 欢迎 {{ username }}!
2 |
3 | 登出
--------------------------------------------------------------------------------
/day-057/templates/login.html:
--------------------------------------------------------------------------------
1 | {% macro render_field(field) %}
2 | {{ field.label }}:
3 | {{ field(**kwargs)|safe }}
4 | {% if field.errors %}
5 |
6 | {% for error in field.errors %}
7 | {{ error }}
8 | {% endfor %}
9 |
10 | {% endif %}
11 |
12 | {% endmacro %}
13 |
14 |
--------------------------------------------------------------------------------
/day-057/templates/signup.html:
--------------------------------------------------------------------------------
1 | {% macro render_field(field) %}
2 | {{ field.label }}:
3 | {{ field(**kwargs)|safe }}
4 | {% if field.errors %}
5 |
6 | {% for error in field.errors %}
7 | {{ error }}
8 | {% endfor %}
9 |
10 | {% endif %}
11 |
12 | {% endmacro %}
13 |
14 |
--------------------------------------------------------------------------------
/day-058/TestProject/TestProject/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-058/TestProject/TestProject/__init__.py
--------------------------------------------------------------------------------
/day-058/TestProject/TestProject/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-058/TestProject/TestProject/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-058/TestProject/TestProject/__pycache__/settings.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-058/TestProject/TestProject/__pycache__/settings.cpython-37.pyc
--------------------------------------------------------------------------------
/day-058/TestProject/TestProject/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-058/TestProject/TestProject/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/day-058/TestProject/TestProject/__pycache__/wsgi.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-058/TestProject/TestProject/__pycache__/wsgi.cpython-37.pyc
--------------------------------------------------------------------------------
/day-058/TestProject/TestProject/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for TestProject project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TestProject.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/day-058/TestProject/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-058/TestProject/db.sqlite3
--------------------------------------------------------------------------------
/day-058/TestProject/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TestProject.settings')
9 | try:
10 | from django.core.management import execute_from_command_line
11 | except ImportError as exc:
12 | raise ImportError(
13 | "Couldn't import Django. Are you sure it's installed and "
14 | "available on your PYTHONPATH environment variable? Did you "
15 | "forget to activate a virtual environment?"
16 | ) from exc
17 | execute_from_command_line(sys.argv)
18 |
19 |
20 | if __name__ == '__main__':
21 | main()
22 |
--------------------------------------------------------------------------------
/day-058/TestProject/polls/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-058/TestProject/polls/__init__.py
--------------------------------------------------------------------------------
/day-058/TestProject/polls/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-058/TestProject/polls/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-058/TestProject/polls/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-058/TestProject/polls/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/day-058/TestProject/polls/__pycache__/views.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-058/TestProject/polls/__pycache__/views.cpython-37.pyc
--------------------------------------------------------------------------------
/day-058/TestProject/polls/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/day-058/TestProject/polls/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class PollsConfig(AppConfig):
5 | name = 'polls'
6 |
--------------------------------------------------------------------------------
/day-058/TestProject/polls/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-058/TestProject/polls/migrations/__init__.py
--------------------------------------------------------------------------------
/day-058/TestProject/polls/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
--------------------------------------------------------------------------------
/day-058/TestProject/polls/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/day-058/TestProject/polls/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path('', views.index, name='index'),
7 | ]
8 |
--------------------------------------------------------------------------------
/day-058/TestProject/polls/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 |
3 | # Create your views here.
4 | from django.http import HttpResponse
5 |
6 | def index(request):
7 | return HttpResponse("你好,这是一个投票页面。")
8 |
--------------------------------------------------------------------------------
/day-059/TestProject/TestProject/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/TestProject/__init__.py
--------------------------------------------------------------------------------
/day-059/TestProject/TestProject/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/TestProject/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-059/TestProject/TestProject/__pycache__/settings.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/TestProject/__pycache__/settings.cpython-37.pyc
--------------------------------------------------------------------------------
/day-059/TestProject/TestProject/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/TestProject/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/day-059/TestProject/TestProject/__pycache__/wsgi.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/TestProject/__pycache__/wsgi.cpython-37.pyc
--------------------------------------------------------------------------------
/day-059/TestProject/TestProject/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for TestProject project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TestProject.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/day-059/TestProject/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/db.sqlite3
--------------------------------------------------------------------------------
/day-059/TestProject/polls/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/polls/__init__.py
--------------------------------------------------------------------------------
/day-059/TestProject/polls/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/polls/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-059/TestProject/polls/__pycache__/admin.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/polls/__pycache__/admin.cpython-37.pyc
--------------------------------------------------------------------------------
/day-059/TestProject/polls/__pycache__/apps.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/polls/__pycache__/apps.cpython-37.pyc
--------------------------------------------------------------------------------
/day-059/TestProject/polls/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/polls/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/day-059/TestProject/polls/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/polls/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/day-059/TestProject/polls/__pycache__/views.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/polls/__pycache__/views.cpython-37.pyc
--------------------------------------------------------------------------------
/day-059/TestProject/polls/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/day-059/TestProject/polls/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class PollsConfig(AppConfig):
5 | name = 'polls'
6 |
--------------------------------------------------------------------------------
/day-059/TestProject/polls/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/polls/migrations/__init__.py
--------------------------------------------------------------------------------
/day-059/TestProject/polls/migrations/__pycache__/0001_initial.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/polls/migrations/__pycache__/0001_initial.cpython-37.pyc
--------------------------------------------------------------------------------
/day-059/TestProject/polls/migrations/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-059/TestProject/polls/migrations/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-059/TestProject/polls/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | class Question(models.Model):
4 | question_text = models.CharField(max_length=200)
5 | pub_date = models.DateTimeField('发布日期')
6 |
7 |
8 | class Choice(models.Model):
9 | question = models.ForeignKey(Question, on_delete=models.CASCADE)
10 | choice_text = models.CharField(max_length=200)
11 | votes = models.IntegerField(default=0)
12 |
--------------------------------------------------------------------------------
/day-059/TestProject/polls/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/day-059/TestProject/polls/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path('', views.index, name='index'),
7 | path('add', views.add, name='add'),
8 | path('query', views.query, name='query'),
9 | path('update', views.update, name='update'),
10 | path('del', views.delete, name='del'),
11 | ]
12 |
--------------------------------------------------------------------------------
/day-060/requests-base-complex.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | import urllib.parse
7 | import urllib.request
8 |
9 | url = "http://www.baidu.com/s"
10 | params = urllib.parse.urlencode({'wd':'python'})
11 | # 发送请求
12 | response = urllib.request.urlopen('?'.join([url, params]))
13 | # 处理响应
14 | print(response.getcode())
15 |
16 |
--------------------------------------------------------------------------------
/day-060/requests-base-headers.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | import requests
7 |
8 | r = requests.get('http://httpbin.org/get')
9 | print(r.status_code)
10 |
11 | print(r.status_code == requests.codes.ok)
12 |
13 | print(r.headers)
14 |
15 | print(r.headers['Content-Encoding'])
16 |
--------------------------------------------------------------------------------
/day-060/requests-base-params.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | import requests
7 |
8 | payload = {'key1': 'value1', 'key2': 'value2'}
9 | r = requests.get("http://httpbin.org/get", params=payload)
10 | print(r.url)
11 |
12 | payload = {'key1': 'value1', 'key2': ['value2', 'value3']}
13 | r = requests.get("http://httpbin.org/get", params=payload)
14 | print(r.url)
15 |
16 |
17 |
--------------------------------------------------------------------------------
/day-060/requests-base-redirect.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | import requests
7 |
8 | r = requests.get('http://github.com')
9 | print(r.url)
10 | print(r.status_code)
11 | print(r.history)
12 |
13 | r = requests.get('http://github.com', allow_redirects=False)
14 | print(r.status_code)
15 | print(r.history)
--------------------------------------------------------------------------------
/day-060/requests-base-response-info.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | import requests
7 |
8 | url = 'http://www.baidu.com'
9 | headers = {'User-Agent': 'myagent/2.21.0'}
10 | r = requests.get(url, headers=headers)
11 | print(r.request.headers)
12 |
13 |
--------------------------------------------------------------------------------
/day-060/requests-base-send-request.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | import requests
7 |
8 | r = requests.get('https://api.github.com/events')
9 | print(r.status_code)
10 |
11 | r = requests.post('http://httpbin.org/post', data = {'key':'value'})
12 | print(r.status_code)
13 |
14 | r = requests.put('http://httpbin.org/put', data = {'key':'value'})
15 | print(r.status_code)
16 |
17 | r = requests.delete('http://httpbin.org/delete')
18 | print(r.status_code)
19 |
20 | r = requests.head('http://httpbin.org/get')
21 | print(r.status_code)
22 |
23 | r = requests.options('http://httpbin.org/get')
24 | print(r.status_code)
--------------------------------------------------------------------------------
/day-060/requests-base-simple.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | import requests
7 |
8 | # 发送请求
9 | response = requests.get(url="http://www.baidu.com/s", params={'wd':'python'})
10 | # 处理响应
11 | print(response.status_code)
--------------------------------------------------------------------------------
/day-060/requests-base-timeout.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | import requests
7 |
8 | requests.get('http://github.com', timeout=0.001)
9 |
--------------------------------------------------------------------------------
/day-060/test.txt:
--------------------------------------------------------------------------------
1 | this is a file test
--------------------------------------------------------------------------------
/day-061/requests-high-auth.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | import requests
7 | from requests.auth import HTTPBasicAuth
8 |
9 | #请将username和password替换成自己在该网站的登录用户名和密码
10 | res = requests.get('http://www.baidu.com', auth=HTTPBasicAuth('username', 'password'))
11 | print(res.status_code)
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/day-061/requests-high-session.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | import requests
7 |
8 | s = requests.Session()
9 | s.get('http://httpbin.org/cookies/set/sessioncookie/123456789')
10 | r = s.get("http://httpbin.org/cookies")
11 | print(r.text)
12 |
13 |
14 | s = requests.Session()
15 | s.auth = ('user', 'pass')
16 | s.headers.update({'x-test': 'true'})
17 |
18 | # both 'x-test' and 'x-test2' are sent
19 | s.get('http://httpbin.org/headers', headers={'x-test2': 'true'})
20 | print(r.text)
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/day-061/requests-high-ssl.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | import requests
7 | from requests.auth import HTTPBasicAuth
8 |
9 | #请将username和password替换成自己在该网站的登录用户名和密码
10 | res = requests.get('http://www.baidu.com', auth=HTTPBasicAuth('username', 'password'))
11 | print(res.status_code)
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/day-062/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-062/__init__.py
--------------------------------------------------------------------------------
/day-062/status_code.py:
--------------------------------------------------------------------------------
1 | import http
2 |
3 | # 打印“OK”对应的状态码
4 | print('"OK" match to "{}"'.format(http.HTTPStatus.OK))
5 |
6 | # 打印“NOT FOUND”对应的状态码
7 | print('"NOT_FOUND" match to "{}"'.format(http.HTTPStatus.NOT_FOUND))
8 |
9 |
10 | # 打印状态码对应的状态短语
11 | while True:
12 | st_code = input("请输入要查询的状态码:(输入 q 退出)\n")
13 |
14 | try:
15 | print("状态为:{}\n".format(http.HTTPStatus(int(st_code)).phrase))
16 | except ValueError:
17 | if st_code == 'q':
18 | break
19 | print("对应的状态码 {} 不存在\n".format(st_code))
20 |
--------------------------------------------------------------------------------
/day-067/pyquery-request-params.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | from pyquery import PyQuery as pq
7 |
8 | cookies = {'Cookie':'cookie'}
9 | headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'}
10 |
11 | response = pq(url='https://www.baidu.com',headers=headers,cookies=cookies)
12 | print(response)
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/day-067/test.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Title
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/day-068/chromedriver-test.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from selenium import webdriver
8 |
9 | browser = webdriver.Chrome()
10 | browser.get('http://www.baidu.com/')
--------------------------------------------------------------------------------
/day-069/selenium-browser-back-forward.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from selenium import webdriver
8 | import time
9 |
10 | # 声明浏览器对象
11 | driver = webdriver.Chrome()
12 | # 访问百度
13 | driver.get("http://www.baidu.com")
14 | time.sleep(2)
15 | # 访问微博
16 | driver.get("https://weibo.com")
17 | time.sleep(2)
18 | # 访问知乎
19 | driver.get("http://www.zhihu.com")
20 | time.sleep(2)
21 | # 返回上个页面
22 | driver.back()
23 | time.sleep(2)
24 | # 前进到下个页面
25 | driver.forward()
26 |
27 | # 退出
28 | driver.close()
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/day-069/selenium-get-element.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 |
4 | """
5 | @author: 闲欢
6 | """
7 |
8 | from selenium import webdriver
9 | from selenium.webdriver.common.by import By
10 |
11 | # 声明浏览器对象
12 | driver = webdriver.Chrome()
13 | # 访问页面
14 | driver.get("http://www.baidu.com")
15 |
16 | # 通过id查找
17 | element = driver.find_element_by_id("kw")
18 | print(element.tag_name)
19 | # 通过name查找
20 | element = driver.find_element_by_name("wd")
21 | print(element.tag_name)
22 | # 通过xpath查找
23 | element = driver.find_element_by_xpath('//*[@id="kw"]')
24 | print(element.tag_name)
25 |
26 | # 通过另一种方式查找
27 | element = driver.find_element(By.ID, "kw")
28 | print(element.tag_name)
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/day-069/selenium-get-elements.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 |
4 | """
5 | @author: 闲欢
6 | """
7 |
8 | from selenium import webdriver
9 | from selenium.webdriver.common.by import By
10 |
11 | # 声明浏览器对象
12 | driver = webdriver.Chrome()
13 | # 访问页面
14 | driver.get("http://www.baidu.com")
15 |
16 | # 查找多个元素
17 | elements = driver.find_elements(By.CLASS_NAME, 'mnav')
18 | for e in elements:
19 | print(e.text)
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/day-069/selenium-implicit-wait.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | from selenium import webdriver
7 | from selenium.webdriver.common.keys import Keys
8 |
9 | # 声明浏览器对象
10 | driver = webdriver.Chrome()
11 |
12 | # 设置隐式等待时间,单位为秒
13 | driver.implicitly_wait(0)
14 |
15 | # 访问页面
16 | driver.get("https://www.baidu.com/")
17 |
18 | # 设置搜索关键词
19 | element = driver.find_element_by_id("kw")
20 | element.send_keys("selenium", Keys.ENTER)
21 |
22 | # 页面右边的"相关术语"
23 | element2 = driver.find_element_by_class_name("opr-recommends-merge-p")
24 | print(element2)
25 |
26 |
--------------------------------------------------------------------------------
/day-069/selenium-open-browser-headless.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from selenium import webdriver
8 |
9 | # 设置无窗口
10 | chrome_options = webdriver.ChromeOptions()
11 | chrome_options.add_argument('--headless')
12 |
13 | # 设置代理
14 | chrome_options.add_argument('--proxy-server=http://{ip}:{port}')
15 |
16 | # 声明浏览器对象
17 | driver = webdriver.Chrome(options=chrome_options)
18 |
19 | # 访问页面
20 | driver.get("http://www.baidu.com")
--------------------------------------------------------------------------------
/day-069/selenium-open-browser.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from selenium import webdriver
8 |
9 | # 声明浏览器对象
10 | driver = webdriver.Chrome()
11 | # 访问页面
12 | driver.get("http://www.baidu.com")
--------------------------------------------------------------------------------
/day-070/itemcsvexporter.py:
--------------------------------------------------------------------------------
1 | from scrapy.conf import settings
2 | # from scrapy.contrib.exporter import CsvItemExporter
3 | from scrapy.exporters import CsvItemExporter
4 | #指定输出到csv文件中字段的顺序,结合setting.py
5 | class itemcsvexporter(CsvItemExporter):
6 | def __init__(self, *args, **kwargs):
7 | delimiter = settings.get('CSV_DELIMITER', ',')
8 | kwargs['delimiter'] = delimiter
9 | fields_to_export = settings.get('FIELDS_TO_EXPORT', [])
10 | if fields_to_export:
11 | kwargs['fields_to_export'] = fields_to_export
12 | super(itemcsvexporter, self).__init__(*args, **kwargs)
13 |
--------------------------------------------------------------------------------
/day-070/items.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import scrapy
3 | class PeilvItem(scrapy.Item):
4 | # define the fields for your item here like:
5 | cc = scrapy.Field()#changci
6 | li = scrapy.Field()#libo
7 | b5 = scrapy.Field()#bet365
8 |
--------------------------------------------------------------------------------
/day-073/mychat1.py:
--------------------------------------------------------------------------------
1 | import itchat
2 | from itchat.content import TEXT
3 |
4 | @itchat.msg_register(TEXT)
5 | def simple_reply(msg):
6 | print(msg.text)
7 |
8 | itchat.auto_login(hotReload=True)
9 | itchat.run()
--------------------------------------------------------------------------------
/day-073/mychat2.py:
--------------------------------------------------------------------------------
1 | import itchat
2 | from itchat.content import TEXT
3 |
4 | # 不带具体对象注册,将注册为普通消息的回复方法
5 | @itchat.msg_register(TEXT)
6 | def simple_reply(msg):
7 | return 'I received: %s' % msg['Text']
8 |
9 | # 带对象参数注册,对应消息对象将调用该方法
10 | @itchat.msg_register(TEXT, isFriendChat=True, isGroupChat=True, isMpChat=False)
11 | def text_reply(msg):
12 | msg.user.send('%s: %s' % (msg.type, msg.text))
13 |
14 |
15 | itchat.auto_login(hotReload=True)
16 | itchat.run()
--------------------------------------------------------------------------------
/day-074/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-074/__init__.py
--------------------------------------------------------------------------------
/day-074/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-074/bg.jpg
--------------------------------------------------------------------------------
/day-074/wc.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-074/wc.jpg
--------------------------------------------------------------------------------
/day-076/github2.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import scrapy
3 | import re
4 |
5 | class Github2Spider(scrapy.Spider):
6 | name = 'github2'
7 | allowed_domains = ['github.com']
8 | start_urls = ['http://github.com/login']
9 |
10 | def parse(self, response):
11 | yield scrapy.FormRequest.from_response(
12 | response, # 自动从response中寻找form表单
13 | formdata={"login": "xxx@qq.com", "password": "xxx"},
14 | callback=self.after_login
15 | )
16 | # 登录成功之后操作
17 | def after_login(self, response):
18 | # 找到页面上的 Issues 字段并打印
19 | print(re.findall("Issues", response.body.decode()))
--------------------------------------------------------------------------------
/day-077/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-077/__init__.py
--------------------------------------------------------------------------------
/day-078/test.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-078/test.db
--------------------------------------------------------------------------------
/day-079/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-079/__init__.py
--------------------------------------------------------------------------------
/day-080/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-080/__init__.py
--------------------------------------------------------------------------------
/day-080/create_table.py:
--------------------------------------------------------------------------------
1 | import pymysql
2 |
3 | # 打开数据库连接
4 | conn = pymysql.connect(
5 | host="127.0.0.1",
6 | user="root",
7 | password="123456",
8 | database="test_db",
9 | charset="utf8")
10 |
11 | # 获取连接下的游标
12 | cursor_test = conn.cursor()
13 |
14 | # 使用 execute() 方法执行 SQL,如果表存在则删除
15 | cursor_test.execute("DROP TABLE IF EXISTS EMPLOYEE")
16 |
17 | # 使用预处理语句创建表
18 | sql = """CREATE TABLE user1 (
19 | FIRST_NAME CHAR(20) NOT NULL,
20 | LAST_NAME CHAR(20),
21 | AGE INT,
22 | SEX CHAR(1),
23 | INCOME FLOAT )"""
24 |
25 | cursor_test.execute(sql)
26 |
27 | # 关闭数据库连接
28 | conn.close()
--------------------------------------------------------------------------------
/day-080/delete_data.py:
--------------------------------------------------------------------------------
1 | # 导入模块
2 | import pymysql
3 |
4 | # 打开数据库连接
5 | conn = pymysql.connect(
6 | host="127.0.0.1",
7 | user="root",
8 | password="123456",
9 | database="test_db",
10 | charset="utf8")
11 | # print(conn)
12 | # print(type(conn))
13 |
14 | # 获取连接下的游标
15 | cursor_test = conn.cursor()
16 |
17 | sql = "DELETE * FROM user1"
18 |
19 | try:
20 | # 执行SQL语句
21 | cursor_test.execute(sql)
22 | # 提交到数据库执行
23 | conn.commit()
24 | except:
25 | # 发生错误时回滚
26 | conn.rollback()
27 |
28 | # 关闭数据库连接
29 | conn.close()
--------------------------------------------------------------------------------
/day-080/insert_data.py:
--------------------------------------------------------------------------------
1 | import pymysql
2 |
3 | # 打开数据库连接
4 | conn = pymysql.connect(
5 | host="127.0.0.1",
6 | user="root",
7 | password="123456",
8 | database="test_db",
9 | charset="utf8")
10 |
11 | # 获取连接下的游标
12 | cursor_test = conn.cursor()
13 |
14 | # 使用预处理语句创建表
15 | sql = """INSERT INTO user1(FIRST_NAME,
16 | LAST_NAME, AGE, SEX, INCOME)
17 | VALUES ('Fei', 'Fei', 20, 'M', 1000)"""
18 |
19 | try:
20 | # 执行sql语句
21 | cursor_test.execute(sql)
22 | # 提交到数据库执行
23 | conn.commit()
24 | except:
25 | # 如果发生错误则回滚
26 | conn.rollback()
27 |
28 | # 关闭数据库连接
29 | conn.close()
--------------------------------------------------------------------------------
/day-080/mysql_test.py:
--------------------------------------------------------------------------------
1 | # 导入模块
2 | import pymysql
3 |
4 | # 打开数据库连接
5 | conn = pymysql.connect(
6 | host="127.0.0.1",
7 | user="root",
8 | password="123456",
9 | database="test_db",
10 | charset="utf8")
11 | # print(conn)
12 | # print(type(conn))
13 |
14 | # 获取连接下的游标
15 | cursor_test = conn.cursor()
16 | # print(cursor_test)
17 |
18 | # 使用 execute() 方法执行 SQL 查询,查询数据库版本
19 | cursor_test.execute("SELECT VERSION()")
20 |
21 | # 使用 fetchone() 方法返回一条数据.
22 | data = cursor_test.fetchone()
23 |
24 | print("Database version : %s " % data)
25 |
26 | # 关闭数据库连接
27 | conn.close()
28 |
29 |
--------------------------------------------------------------------------------
/day-080/update_test.py:
--------------------------------------------------------------------------------
1 | # 导入模块
2 | import pymysql
3 |
4 | # 打开数据库连接
5 | conn = pymysql.connect(
6 | host="127.0.0.1",
7 | user="root",
8 | password="123456",
9 | database="test_db",
10 | charset="utf8")
11 | # print(conn)
12 | # print(type(conn))
13 |
14 | # 获取连接下的游标
15 | cursor_test = conn.cursor()
16 |
17 | sql = "UPDATE EMPLOYEE SET AGE = AGE + 1 WHERE SEX = '%c'" % ('M')
18 |
19 | try:
20 | # 执行SQL语句
21 | cursor_test.execute(sql)
22 | # 提交到数据库执行
23 | conn.commit()
24 | except:
25 | # 发生错误时回滚
26 | conn.rollback()
27 |
28 | # 关闭数据库连接
29 | conn.close()
--------------------------------------------------------------------------------
/day-081/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-081/__init__.py
--------------------------------------------------------------------------------
/day-086/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-086/__init__.py
--------------------------------------------------------------------------------
/day-086/foo.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-086/foo.db
--------------------------------------------------------------------------------
/day-088-flask-OAuth/templates/home.html:
--------------------------------------------------------------------------------
1 | {% if user %}
2 |
3 | {{ user|tojson }}
4 |
5 | logout
6 | {% else %}
7 | login
8 | {% endif %}
--------------------------------------------------------------------------------
/day-090-numpy/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-090-numpy/__init__.py
--------------------------------------------------------------------------------
/day-091-matplotlib/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-091-matplotlib/__init__.py
--------------------------------------------------------------------------------
/day-091-matplotlib/matplotlib-exam1.py:
--------------------------------------------------------------------------------
1 | import matplotlib.pyplot as plt
2 |
3 | # 示例1 简单绘图示例
4 | plt.plot([1, 2], [1, 2], 'r--+')
5 | plt.show()
6 |
7 | # 示例2
8 | # 指定一个画板
9 | fig = plt.figure()
10 | # 指定画板后指定轴
11 | # ax = fig.add_subplot(111)
12 | ax1 = fig.add_subplot(221)
13 | ax2 = fig.add_subplot(222)
14 | ax3 = fig.add_subplot(224)
15 | ax4 = fig.add_subplot(223)
16 | # 设置轴的位置
17 | # ax.set(xlim=[0.5, 4.5], ylim=[-2, 8], title='An Example Axes',
18 | # ylabel='Y-Axis', xlabel='X-Axis')
19 | plt.show()
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/day-091-matplotlib/matplotlib-exam2.py:
--------------------------------------------------------------------------------
1 | import matplotlib.pyplot as plt
2 |
3 | x = (1,3,5,9,13)
4 |
5 | y = (2,5,9,12,28)
6 |
7 | # 调用绘制方法
8 | # 设置线条属性
9 | plt.plot(x,y,linewidth = 5)
10 |
11 | # 显示图片
12 | plt.show()
13 |
14 |
--------------------------------------------------------------------------------
/day-092/MatPlotlib_test.py:
--------------------------------------------------------------------------------
1 | import matplotlib.pyplot as plt
2 |
3 | # 示例1 简单绘图示例
4 | plt.plot([1, 2], [1, 2], 'r--+')
5 | plt.show()
6 |
7 | # 示例2
8 | # 指定一个画板
9 | fig = plt.figure()
10 | # 指定画板后指定轴
11 | # ax = fig.add_subplot(111)
12 | ax1 = fig.add_subplot(221)
13 | ax2 = fig.add_subplot(222)
14 | ax3 = fig.add_subplot(224)
15 | ax4 = fig.add_subplot(223)
16 | # 设置轴的位置
17 | # ax.set(xlim=[0.5, 4.5], ylim=[-2, 8], title='An Example Axes',
18 | # ylabel='Y-Axis', xlabel='X-Axis')
19 | plt.show()
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/day-092/Triangle_scat_chart.py:
--------------------------------------------------------------------------------
1 | # 导入模块
2 | import numpy as np
3 | import matplotlib.pyplot as plt
4 |
5 | x = np.arange(2, 15)
6 | y = 2 * x + 6
7 | plt.title("triangle_scatter chart")
8 | plt.xlabel("x axis")
9 | plt.ylabel("y axis")
10 |
11 | # 设置图形样式和颜色
12 | plt.plot(x, y, "^c")
13 | plt.show()
--------------------------------------------------------------------------------
/day-092/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-092/__init__.py
--------------------------------------------------------------------------------
/day-092/bar_chart.py:
--------------------------------------------------------------------------------
1 | import matplotlib.pyplot as plt
2 |
3 | # 设置 x 的 x 轴和 y 轴数值
4 | x = [5,8,10]
5 | y = [12,16,6]
6 |
7 | # 设置 x2 的 x 轴和 y 轴数值
8 | x2 = [6,9,11]
9 | y2 = [6,15,7]
10 |
11 | # 使用 bar() 函数设置条形图的颜色和对齐方式
12 | plt.bar(x, y,color='y', align='center')
13 | plt.bar(x2, y2, color='c', align='center')
14 |
15 | # 设置标题
16 | plt.title('Bar chart')
17 | # 设置 x 轴和 y 轴的属性名
18 | plt.ylabel('Y axis')
19 | plt.xlabel('X axis')
20 |
21 | # 展示图形
22 | plt.show()
--------------------------------------------------------------------------------
/day-092/basic_exce.py:
--------------------------------------------------------------------------------
1 | import matplotlib.pyplot as plt
2 |
3 | x = (1, 3, 5, 9, 13)
4 |
5 | y = (2, 5, 9, 12, 28)
6 |
7 | # 调用绘制方法
8 | # 设置线条属性
9 | plt.plot(x, y, linewidth=5)
10 |
11 | # 显示图片
12 | plt.show()
13 |
--------------------------------------------------------------------------------
/day-092/cosine_chart.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import matplotlib.pyplot as plt
3 |
4 | # 计算正弦曲线上点的 x 和 y 坐标
5 | print(np.pi)
6 |
7 | # 绘制 x 轴,从 0 开始,
8 | x = np.arange(0, 4 * np.pi, 0.1)
9 | y = np.cos(x)
10 |
11 | # 设置标题
12 | plt.title("cosine wave form")
13 |
14 | # 绘制图形点
15 | plt.plot(x, y, 'm')
16 | plt.show()
--------------------------------------------------------------------------------
/day-092/curve_chart1.py:
--------------------------------------------------------------------------------
1 | import matplotlib.pyplot as plt
2 | import numpy as np
3 |
4 | n = 256
5 | X = np.linspace(-np.pi,np.pi,n,endpoint=True)
6 | Y = np.sin(2*X)
7 |
8 | plt.plot (X, Y+1, color='blue', alpha=1.00)
9 | plt.plot (X, Y-1, color='blue', alpha=1.00)
10 |
11 | plt.title('curve_chart1')
12 | plt.show()
13 |
14 |
--------------------------------------------------------------------------------
/day-092/curve_chart2.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import matplotlib.pyplot as plt
3 |
4 | n = 256
5 | X = np.linspace(-np.pi,np.pi,n,endpoint=True)
6 | Y = np.sin(2*X)
7 |
8 | plt.plot (X, Y+1, color='blue', alpha=1.00)
9 | plt.fill_between(X, 1, Y+1, color='blue', alpha=.25)
10 |
11 | plt.plot (X, Y-1, color='blue', alpha=1.00)
12 |
13 | # 设置线条颜色和填充颜色区域
14 | plt.fill_between(X, -1, Y-1, (Y-1) > -1, color='blue', alpha=.25)
15 | plt.fill_between(X, -1, Y-1, (Y-1) < -1, color='red', alpha=.25)
16 |
17 | plt.title('curve_chart2')
18 | plt.show()
19 |
--------------------------------------------------------------------------------
/day-092/line_chart.py:
--------------------------------------------------------------------------------
1 | # 导入模块
2 | import numpy as np
3 | import matplotlib.pyplot as plt
4 |
5 | # 绘制 x 轴数据
6 | x = np.arange(2, 15)
7 | y = 3 * x+6
8 |
9 | # 给图形设置标题
10 | plt.title('line chart')
11 | # 设置 x 轴和 y 轴的属性名
12 | plt.xlabel("x axis")
13 | plt.ylabel("y axis")
14 |
15 | # 绘制图形
16 | plt.plot(x,y)
17 |
18 | # 显示图形
19 | plt.show()
--------------------------------------------------------------------------------
/day-092/numpy_exam.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import matplotlib.pyplot as plt
3 |
4 | # 赋值数组 a
5 | a = np.array([22, 87, 43, 56, 73, 55, 11, 20, 51, 5, 79, 27,100])
6 |
7 | # plt() 函数将数据变为直方图
8 | plt.hist(a, bins=[0,20,40,60,80,100])
9 | plt.title("histogram")
10 | # 显示图形
11 | plt.show()
12 |
13 | # 调用函数
14 | np.histogram(a, bins=[0, 20, 40, 60, 80, 100])
15 | hist, bins = np.histogram(a, bins=[0, 20, 40, 60, 80, 100])
16 |
17 | # 输出值
18 | print(hist)
19 | print(bins)
20 |
21 |
--------------------------------------------------------------------------------
/day-092/opera-matplotlib.py:
--------------------------------------------------------------------------------
1 |
2 | import numpy as np
3 |
4 | import matplotlib.pyplot as plt
5 |
6 | # np.linspace() 是等差数列函数,返回num均匀分布的样本,在[start, stop]
7 |
8 | X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
9 |
10 | C,S = np.cos(X), np.sin(X)
11 |
12 | plt.plot(X,C)
13 | plt.plot(X,S)
14 |
15 | plt.show()
16 |
17 |
18 |
--------------------------------------------------------------------------------
/day-092/scatter_chart.py:
--------------------------------------------------------------------------------
1 | # 导入模块
2 | import numpy as np
3 | import matplotlib.pyplot as plt
4 |
5 | x = np.arange(2, 15)
6 | y = 2 * x + 6
7 | plt.title("scatter chart")
8 | plt.xlabel("x axis")
9 | plt.ylabel("y axis")
10 |
11 | # 设置图形样式和颜色
12 | plt.plot(x, y, "oc")
13 | plt.show()
--------------------------------------------------------------------------------
/day-092/sin_cos_chart.py:
--------------------------------------------------------------------------------
1 | # 导入模块
2 | import numpy as np
3 | import matplotlib.pyplot as plt
4 |
5 | # 计算正弦和余弦曲线上的点的 x 和 y 坐标
6 | x = np.arange(0, 3 * np.pi, 0.1)
7 | y_sin = np.sin(x)
8 | y_cos = np.cos(x)
9 |
10 | # 建立 subplot 网格,高为 2,宽为 1
11 | # 激活第一个 subplot
12 | plt.subplot(2, 1, 1)
13 | # 绘制第一个图像
14 | plt.plot(x, y_sin)
15 | plt.title('Sine')
16 |
17 | # 将第二个 subplot 激活,并绘制第二个图像
18 | plt.subplot(2, 1, 2)
19 | plt.plot(x, y_cos)
20 | plt.title('Cosine')
21 |
22 | # 展示图像
23 | plt.show()
--------------------------------------------------------------------------------
/day-092/sine_chart.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import matplotlib.pyplot as plt
3 |
4 | # 计算正弦曲线上点的 x 和 y 坐标
5 | print(np.pi)
6 |
7 | # 绘制 x 轴,从 0 开始,
8 | x = np.arange(0, 3 * np.pi, 0.1)
9 | y = np.sin(x)
10 |
11 | # 设置标题
12 | plt.title("sine wave form")
13 |
14 | # 绘制图形点
15 | plt.plot(x, y, 'y')
16 | plt.show()
--------------------------------------------------------------------------------
/day-092/subplot/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-092/subplot/__init__.py
--------------------------------------------------------------------------------
/day-092/subplot/axes.py:
--------------------------------------------------------------------------------
1 | import matplotlib.pyplot as plt
2 | plt.axes([0.1,0.1,.8,.8])
3 | plt.xticks([]), plt.yticks([])
4 | plt.text(0.6,0.6, 'axes([0.1,0.1,.8,.8])',ha='center',va='center',size=20,alpha=.5)
5 |
6 | plt.axes([0.2,0.2,.3,.3])
7 | plt.xticks([]), plt.yticks([])
8 | plt.text(0.5,0.5, 'axes([0.2,0.2,.3,.3])',ha='center',va='center',size=16,alpha=.5)
9 |
10 | # plt.savefig("../figures/axes.png",dpi=64)
11 | plt.show()
12 |
--------------------------------------------------------------------------------
/day-092/subplot/subplot-grid.py:
--------------------------------------------------------------------------------
1 | import matplotlib.pyplot as plt
2 |
3 | plt.subplot(2,2,1)
4 | plt.xticks([]), plt.yticks([])
5 | plt.text(0.5,0.5, 'subplot(2,2,1)',ha='center',va='center',size=20,alpha=.5)
6 |
7 | plt.subplot(2,2,2)
8 | plt.xticks([]),plt.yticks([])
9 | plt.text(0.5,0.5, 'subplot(2,2,2)',ha='center',va='center',size=20,alpha=.5)
10 |
11 | plt.subplot(2,2,3)
12 | plt.xticks([]), plt.yticks([])
13 | plt.text(0.5,0.5, 'subplot(2,2,3)',ha='center',va='center',size=20,alpha=.5)
14 |
15 | plt.subplot(2,2,4)
16 | plt.xticks([]), plt.yticks([])
17 | plt.text(0.5,0.5, 'subplot(2,2,4)',ha='center',va='center',size=20,alpha=.5)
18 |
19 | plt.show()
20 |
--------------------------------------------------------------------------------
/day-092/subplot/subplot-horizontal.py:
--------------------------------------------------------------------------------
1 | import matplotlib.pyplot as plt
2 |
3 | plt.subplot(2,1,1)
4 | #设置 x 和 y 轴上的值
5 | plt.xticks([]), plt.yticks([]) # 表示无显示值
6 | plt.text(0.5,0.5, 'subplot(2,1,1)',ha='center',va='center',size=24,alpha=.5)
7 |
8 | plt.subplot(2,1,2)
9 | plt.xticks([]), plt.yticks([])
10 | plt.text(0.5,0.5, 'subplot(2,1,2)',ha='center',va='center',size=24,alpha=.5)
11 |
12 | plt.show()
13 |
--------------------------------------------------------------------------------
/day-092/subplot/subplot-vertical.py:
--------------------------------------------------------------------------------
1 | import matplotlib.pyplot as plt
2 |
3 | plt.subplot(1,2,1)
4 | plt.xticks([]), plt.yticks([])
5 | plt.text(0.5,0.5, 'subplot(2,2,1)',ha='center',va='center',size=24,alpha=.5)
6 |
7 | plt.subplot(1,2,2)
8 | plt.xticks([]), plt.yticks([])
9 | plt.text(0.5,0.5, 'subplot(2,2,2)',ha='center',va='center',size=24,alpha=.5)
10 |
11 | plt.show()
12 |
--------------------------------------------------------------------------------
/day-092/subplot/subplot_chart.py:
--------------------------------------------------------------------------------
1 | import matplotlib
2 | import matplotlib.pyplot as plt
3 |
4 | plt.subplot(211) # 第一行的左图
5 | plt.subplot(212) # 第一行的右图
6 |
7 | plt.show()
--------------------------------------------------------------------------------
/day-094/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-094/__init__.py
--------------------------------------------------------------------------------
/day-096/cat.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-096/cat.jpg
--------------------------------------------------------------------------------
/day-096/cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-096/cat.png
--------------------------------------------------------------------------------
/day-096/flower.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-096/flower.jpg
--------------------------------------------------------------------------------
/day-096/image-blend.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | from PIL import Image
7 |
8 | # 蓝色图像
9 | image1 = Image.new('RGB', (128, 128), (0, 0, 255))
10 | # 红色图像
11 | image2=Image.new('RGB', (128, 128), (255, 0, 0))
12 | # 取中间值
13 | im = Image.blend(image1, image2, 0.5)
14 | image1.show()
15 | image2.show()
16 | # 显示紫色图像,因为红色叠加蓝色会调和成紫色
17 | im.show()
18 |
--------------------------------------------------------------------------------
/day-096/image-change-suffix.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from PIL import Image
8 |
9 | # 加载 cat.jpg
10 | im = Image.open('cat.jpg', 'r')
11 |
12 | # 打印图片类型
13 | print(im.format)
14 |
15 | # 保存为 png 类型图片
16 | im.save('cat.png')
17 |
18 | # 加载新保存的 png 类型图片
19 | im2 = Image.open('cat.png', 'r')
20 |
21 | # 打印新保存图片类型
22 | print(im2.format)
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/day-096/image-composite.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | from PIL import Image
7 |
8 | # 打开 cat.png
9 | image1 = Image.open('cat.png')
10 |
11 | # 打开 flower.jpg
12 | image2 = Image.open('flower.jpg')
13 |
14 | # 分离image1的通道
15 | r, g, b = image1.split()
16 |
17 | # 合成图像,获得 cat + flower
18 | im = Image.composite(image1, image2, mask=b)
19 |
20 | image1.show()
21 | image2.show()
22 | im.show()
23 |
--------------------------------------------------------------------------------
/day-096/image-create.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from PIL import Image
8 |
9 | im = Image.new('RGB', (450, 450), (255, 0, 0))
10 | im1 = Image.new('RGB', (450, 450), 'red')
11 | im2 = Image.new('RGB', (450, 450), '#FF0000')
12 | im.show()
13 | im1.show()
14 | im2.show()
15 |
16 |
--------------------------------------------------------------------------------
/day-096/image-eval.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from PIL import Image
8 |
9 | im = Image.open('cat.jpg')
10 | im.show()
11 |
12 | # 将每个像素值翻倍(相当于亮度翻倍)
13 | evl1 = Image.eval(im, lambda x: x*2)
14 | evl1.show()
15 |
16 | # 将每个像素值减半(相当于亮度减半)
17 | evl2 = Image.eval(im, lambda x: x/2)
18 | evl2.show()
19 |
20 |
21 |
--------------------------------------------------------------------------------
/day-096/image-merge.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from PIL import Image
8 |
9 | im = Image.open('cat.png')
10 | # 将三个通道分开
11 | im_split = im.split()
12 |
13 | # 分别显示三个单通道图像
14 | im_split[0].show()
15 | im_split[1].show()
16 | im_split[2].show()
17 |
18 | # 将三个通道再次合并
19 | im2 = Image.merge('RGB', im_split)
20 | im2.show()
21 |
22 | # 打开第二张图像
23 | im3 = Image.open('flower.jpg')
24 | # 将第二张图像的三个通道分开
25 | im_split2 = im3.split()
26 |
27 | # 将第二张图像的第1个通道和第一张图像的第2、3通道合成一张图像
28 | rgbs = [im_split2[0], im_split[1], im_split[2]]
29 | im4 = Image.merge('RGB', rgbs)
30 | im4.show()
31 |
32 |
33 |
--------------------------------------------------------------------------------
/day-096/image-open.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | from PIL import Image
7 | from io import BytesIO
8 | import requests
9 |
10 | # 打开图像文件
11 | im = Image.open('cat.jpg')
12 |
13 | # 打印图像的格式、大小、模式
14 | print(im.format, im.size, im.mode)
15 |
16 | # 从文件流中打开图像
17 | r = requests.get('http://f.hiphotos.baidu.com/image/pic/item/b151f8198618367aa7f3cc7424738bd4b31ce525.jpg')
18 | im2 = Image.open(BytesIO(r.content))
19 |
20 | # 打印图像的格式、大小、模式
21 | print(im2.format, im2.size, im2.mode)
22 |
23 | # 展示图像
24 | im.show()
25 | im2.show()
26 |
27 | # 翻转90度展示
28 | im.rotate(90).show()
--------------------------------------------------------------------------------
/day-096/image-thumbnail.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from PIL import Image
8 |
9 | # 加载图像
10 | im = Image.open('cat.png')
11 |
12 | # 展示图像
13 | im.show()
14 |
15 | # 图像尺寸
16 | size = 128, 128
17 | # 缩放图像
18 | im.thumbnail(size, Image.ANTIALIAS)
19 |
20 | # 展示图像
21 | im.show()
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/day-097/cat.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-097/cat.jpg
--------------------------------------------------------------------------------
/day-097/cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-097/cat.png
--------------------------------------------------------------------------------
/day-097/flower.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-097/flower.jpg
--------------------------------------------------------------------------------
/day-097/image-band.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from PIL import Image
8 |
9 | # 打开图像
10 | im = Image.open('cat.jpg')
11 | # 创建新图像
12 | im1 = Image.new('L', (450, 450), 50)
13 |
14 | # 获取图像的通道名称元组
15 | print(im.getbands())
16 | print(im1.getbands())
17 |
18 |
--------------------------------------------------------------------------------
/day-097/image-bbox.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from PIL import Image
8 |
9 | # 打开图像(451x300)
10 | im = Image.open('cat.jpg')
11 | # 创建新图像(450x450)
12 | im1 = Image.new('L', (450, 450), 50)
13 |
14 | # 打印图像中非零区域的边界框
15 | print(im.getbbox())
16 | print(im1.getbbox())
17 |
18 |
--------------------------------------------------------------------------------
/day-097/image-convert.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from PIL import Image
8 |
9 | im = Image.open('cat.png')
10 | im.show()
11 | # 将图像转换成黑白色并返回新图像
12 | im1 = im.convert('L')
13 | im1.show()
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/day-097/image-crop.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | from PIL import Image
7 |
8 | im = Image.open('cat.jpg')
9 | print(im.size)
10 | im.show()
11 |
12 | # 定义了图像的坐标位置,从左、上、右、下
13 | box = (100, 100, 250, 250)
14 |
15 | # 它会从左上角开始,同时向下和向右移动100像素的位置开始截取250-100的像素宽高,也就是150x150的图像
16 | # 这里注意后两个数值要大于前两个数值,不然截取后的图像宽高为负数,会报错
17 | region = im.crop(box)
18 | print(region.size)
19 | region.show()
20 |
--------------------------------------------------------------------------------
/day-097/image-filter.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | from PIL import Image
7 | from PIL import ImageFilter
8 |
9 |
10 | im = Image.open('flower.jpg')
11 | im.show()
12 |
13 | # 模糊
14 | im2 = im.filter(ImageFilter.BLUR)
15 | im2.show()
16 |
17 | # 轮廓滤波
18 | im3 = im.filter(ImageFilter.CONTOUR)
19 | im3.show()
20 |
21 | # 细节增强
22 | im4 = im.filter(ImageFilter.DETAIL)
23 | im4.show()
24 |
25 |
--------------------------------------------------------------------------------
/day-097/image-getcolors.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | from PIL import Image
8 |
9 | im = Image.open('cat.png')
10 |
11 | # 将彩色图像转换成灰度图
12 | im2 = im.convert("L")
13 |
14 | # 打印灰度图的颜色列表,返回的点数超过maxcolors就直接返回None
15 | print(im2.getcolors(maxcolors=200))
16 | print(im2.getcolors(maxcolors=255))
17 |
18 | print(im2.getextrema())
19 |
20 |
21 |
--------------------------------------------------------------------------------
/day-097/image-point.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | from PIL import Image
7 |
8 | im = Image.open('cat.png')
9 |
10 | # 调整灰色图像的对比度
11 | im_point=im.convert('L').point(lambda i: i < 80 and 255)
12 | im_point.show()
13 |
14 | source = im.split()
15 | # 三通道分别处理对比度(当像素值小于80时,将其调整为255,相当于)
16 | band_r = source[0].point(lambda i: i < 80 and 255)
17 | band_g = source[1].point(lambda i: i < 80 and 255)
18 | band_b = source[2].point(lambda i: i < 80 and 255)
19 | band_r.show()
20 | band_g.show()
21 | band_b.show()
22 |
--------------------------------------------------------------------------------
/day-097/image-resize.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | from PIL import Image
7 |
8 | im = Image.open('flower.jpg')
9 |
10 | img1 = im.resize((250, 250), Image.BILINEAR)
11 | img2 = im.resize((250, 250), Image.BICUBIC)
12 | img3 = im.resize((250, 250), Image.NEAREST)
13 |
14 | im.show()
15 | img1.show()
16 | img2.show()
17 | img3.show()
--------------------------------------------------------------------------------
/day-098/binary.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-098/binary.png
--------------------------------------------------------------------------------
/day-098/grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-098/grey.png
--------------------------------------------------------------------------------
/day-098/result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-098/result.png
--------------------------------------------------------------------------------
/day-098/vc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-098/vc.png
--------------------------------------------------------------------------------
/day-099/tcp-client.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | import socket
8 | import time
9 |
10 | # 创建 socket
11 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
12 |
13 | # 建立连接
14 | s.connect(("127.0.0.1", 6000))
15 |
16 | # 接收服务器消息
17 | print(s.recv(1024).decode())
18 |
19 | for data in [b'Michael', b'Tracy', b'Sarah']:
20 | # 发送数据
21 | s.send(data)
22 | time.sleep(2)
23 | # 打印接收到的数据
24 | print(s.recv(1024).decode('utf-8'))
25 | time.sleep(1)
26 |
27 | time.sleep(3)
28 | # 请求退出
29 | s.send(b'exit')
30 | time.sleep(2)
31 | print(s.recv(1024).decode('utf-8'))
32 |
33 | # 关闭连接
34 | s.close()
35 |
36 |
37 |
--------------------------------------------------------------------------------
/day-100-01/三木板模型算法项目实战:
--------------------------------------------------------------------------------
1 | 机器学习思路:
2 | 选取未来这场比赛中8个特征中的任何三个特征组合(如2.14,2.15,2.1)与历史数据所有行中对应特征(易胜博、立博、bet365)组合进行比对,发现三个特征值完全相同就统计res列比赛结果y或n的数量。循环其他任意三个特征组合,直到取完C83种组合为止。
3 | 如果历史数据中存在组合对象结果y大于3倍的n时,记录。或n大于3倍的y时,也同样记录。最后根据综合结果来预测未来的这场比赛可能出现的比赛结果。
4 |
5 | 评估模型的建立是为了对建立的机器学习模型进行有效评估,对预测正确的部分进行加强学习,对预测错误的部分进行权重调整,从而达到完善模型的目的。
6 |
--------------------------------------------------------------------------------
/day-100/udp-client.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 | import socket
7 |
8 | # 创建 socket
9 | sk = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
10 | addr = ('127.0.0.1', 6000)
11 | while True:
12 | # 等待输入
13 | msg = input('>>>')
14 | # 发送数据报
15 | sk.sendto(msg.encode('utf-8'), addr)
16 | # 接收数据报
17 | msg_recv, addr = sk.recvfrom(1024)
18 | # 打印
19 | print(msg_recv.decode('utf-8'))
20 |
21 | # 关闭 socket
22 | sk.close()
23 |
--------------------------------------------------------------------------------
/day-100/udp-server.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | @author: 闲欢
5 | """
6 |
7 | import socket
8 |
9 | # 创建 socket
10 | sk = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
11 | # 绑定 IP 和端口号
12 | sk.bind(('127.0.0.1', 6000))
13 | while True:
14 | # 接收数据报
15 | msg, addr = sk.recvfrom(1024)
16 | # 打印
17 | print('来自[%s:%s]的消息: %s' % (addr[0], addr[1], msg.decode('utf-8')))
18 |
19 | # 等待输入
20 | inp = input('>>>')
21 | # 发送数据报
22 | sk.sendto(inp.encode('utf-8'), addr)
23 |
24 | # 关闭 socket
25 | sk.close()
26 |
--------------------------------------------------------------------------------
/day-101-01/Python XGBoost算法项目实战:
--------------------------------------------------------------------------------
1 | 说明:以上两个文件是XGBoost两个算法的实现:分类与回归。
2 |
--------------------------------------------------------------------------------
/day-101/simple_asyncio.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | async def do_work():
4 | print("Hello....")
5 | # 模拟阻塞1秒
6 | await asyncio.sleep(1)
7 | print("world...")
8 |
9 | coroutine = do_work()
10 | print(coroutine)
11 |
12 | # 创建一个事件event_loop
13 | loop = asyncio.get_event_loop()
14 |
15 | # 将协程加入到event_loop中,并运行
16 | loop.run_until_complete(coroutine)
17 |
--------------------------------------------------------------------------------
/day-101/single_callback_asyncio.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | import functools
3 |
4 |
5 | async def do_work(t):
6 | print("暂停" + str(t) + "秒")
7 | await asyncio.sleep(t)
8 | return "暂停了" + str(t) + "秒"
9 |
10 |
11 | def callback(loop, gatheringFuture):
12 | print(gatheringFuture)
13 | print("多个Task任务完成后的回调")
14 | loop.stop()
15 |
16 |
17 | loop = asyncio.get_event_loop()
18 |
19 | gather = asyncio.gather(do_work(1), do_work(3))
20 | gather.add_done_callback(functools.partial(callback, loop))
21 |
22 | loop.run_forever()
23 |
--------------------------------------------------------------------------------
/day-101/task_asyncio.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 |
4 | async def do_work():
5 | print("这是一个Task例子....")
6 | # 模拟阻塞1秒
7 | await asyncio.sleep(1)
8 | return "Task任务完成"
9 |
10 | # 创建一个事件event_loop
11 | loop = asyncio.get_event_loop()
12 |
13 | # 创建一个task
14 | task = loop.create_task(do_work())
15 | # 第一次打印task
16 | print(task)
17 |
18 | # 将task加入到event_loop中
19 | loop.run_until_complete(task)
20 | # 再次打印task
21 | print(task)
22 | print(task.result())
23 |
--------------------------------------------------------------------------------
/day-101/task_callback_asyncio.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | async def do_work():
4 | print("这是一个Task例子....")
5 | # 模拟阻塞1秒
6 | await asyncio.sleep(1)
7 | return "Task任务完成"
8 |
9 | # 任务完成后的回调函数
10 | def callback(task):
11 | # 打印参数
12 | print(task)
13 | # 打印返回的结果
14 | print(task.result())
15 |
16 | # 创建一个事件event_loop
17 | loop = asyncio.get_event_loop()
18 |
19 | # 创建一个task
20 | task = loop.create_task(do_work())
21 | task.add_done_callback(callback)
22 |
23 | # 将task加入到event_loop中
24 | loop.run_until_complete(task)
25 |
--------------------------------------------------------------------------------
/day-102-01/1.2.1.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-102-01/1.2.1.py
--------------------------------------------------------------------------------
/day-102-01/1.2.2.py:
--------------------------------------------------------------------------------
1 | # 打开 'python-100.txt' 文件,如果文件不存在会在程序文件 *.py 所在的目录下创建该文件。
2 |
3 | with open('python-100.txt', 'w') as f:
4 |
5 | print('测试1:python-100.txt 文件已打开。')
6 |
7 | print('测试1:python-100.txt 文件已关闭。')
8 |
9 | # 打开 'C:\Users\Desktop\py' 路径下的 'python-100.txt' 文件。
10 |
11 | with open('C:\\\\Users\\\\Desktop\\\\py\\\\python-100.txt', 'w') as f:
12 |
13 | print('测试2:python-100.txt 文件已打开。')
14 |
15 | print('测试2:python-100.txt 文件已关闭。')
--------------------------------------------------------------------------------
/day-102-01/2.2.1.py:
--------------------------------------------------------------------------------
1 | # 以 r 模式打开本地建立的 python-100.txt 文件,以 'utf-8' 编码读取文件中的所有内容
2 |
3 | with open('python-100.txt', 'r', encoding='utf-8') as f:
4 | content = f.read()
5 | print(content)
6 |
7 | # 输出结果
8 | # Python-100
9 | # 坚持100天
--------------------------------------------------------------------------------
/day-102-01/2.2.2.py:
--------------------------------------------------------------------------------
1 | # 1.以 r 模式打开本地建立的 python-100.txt 文件,每次读取 n 个字符
2 |
3 | with open('python-100.txt', 'r', encoding='utf-8') as f:
4 | content = f.read(8)
5 | print(content)
6 |
7 | content = f.read(8)
8 | print(content)
9 |
10 | # 输出结果(注意:每次读取到的换行符 '\n' 也是算一个字符的,换行符位于每行内容的末尾)
11 | # Python-1
12 | # 00
13 | # 坚持100
14 |
15 | # 2.以 rb 模式打开本地建立的 python-100.txt 文件,每次读取 n 个字节,注意是字节
16 |
17 | with open('python-100.txt', 'rb') as f:
18 | content = f.read(8)
19 | print(content)
20 |
21 | content = f.read(8)
22 | print(content)
23 |
24 | # 输出结果
25 | # b'Python-1'
26 | # b'00\r\n\xe5\x9d\x9a\xe6'
--------------------------------------------------------------------------------
/day-102-01/2.2.3.py:
--------------------------------------------------------------------------------
1 | # 以 r 模式打开本地建立的 python-100.txt 文件,每次读取文件中的一行内容,利用 strip() 函数去掉每一行末尾的换行符
2 |
3 | with open('python-100.txt', 'r', encoding='utf-8') as f:
4 | firstLine = f.readline().strip('\n')
5 | secondLine = f.readline().strip('\n')
6 |
7 | print(firstLine)
8 | print(secondLine)
9 |
10 | # 输出结果
11 | # Python-100
12 | # 坚持100天
--------------------------------------------------------------------------------
/day-102-01/2.2.4.py:
--------------------------------------------------------------------------------
1 | # 以 r 模式打开本地建立的 python-100.txt 文件,读取文件中所有内容,以列表形式返回
2 |
3 | with open('python-100.txt', 'r', encoding='utf-8') as f:
4 | content = f.readlines()
5 | print(content)
6 |
7 | for line in content:
8 | print(line.strip('\n'))
9 |
10 | # 输出结果
11 | # ['Python-100\n', '坚持100天']
12 | # Python-100
13 | # 坚持100天
--------------------------------------------------------------------------------
/day-102-01/2.2.5.py:
--------------------------------------------------------------------------------
1 | # 每次读取一行内容,该方法较为实用
2 |
3 | with open('python-100.txt', 'r', encoding='utf-8') as f:
4 | for line in f:
5 | print(line.strip('\n'))
6 |
7 | # 输出结果
8 | # Python-100
9 | # 坚持100天
--------------------------------------------------------------------------------
/day-102-01/2.3.1.py:
--------------------------------------------------------------------------------
1 | # 以 r 模式打开本地建立的空文件 python-100.txt,向文件中写入内容并读取
2 |
3 | f = open('python-100.txt', 'w', encoding='utf-8')
4 |
5 | f.write('Python-100\n')
6 | f.write('坚持100天')
7 |
8 | f.close()
9 |
10 | f = open('python-100.txt', 'r', encoding='utf-8')
11 |
12 | print(f.read())
13 |
14 | f.close()
15 |
16 | # 输出结果
17 | # Python-100
18 | # 坚持100天
--------------------------------------------------------------------------------
/day-102-01/2.3.2.py:
--------------------------------------------------------------------------------
1 | # 以 r 模式打开本地建立的空文件 python-100.txt,向文件中写入内容并读取
2 |
3 | f = open('python-100.txt', 'w', encoding='utf-8')
4 |
5 | content = ['Python-100\n', '坚持100天']
6 | f.writelines(content)
7 |
8 | f.close()
9 |
10 | f = open('python-100.txt', 'r', encoding='utf-8')
11 | print(f.read())
12 |
13 | f.close()
14 |
15 | # 输出结果
16 | # Python-100
17 | # 坚持100天
--------------------------------------------------------------------------------
/day-102/aiohttp_cookies.py:
--------------------------------------------------------------------------------
1 | import aiohttp
2 | import asyncio
3 | from datetime import datetime
4 |
5 |
6 | async def fetch(client):
7 | async with client.get('http://httpbin.org/get') as resp:
8 | return await resp.text()
9 |
10 |
11 | async def main():
12 | cookies = {'cookies': 'this is cookies'}
13 | async with aiohttp.ClientSession(cookies=cookies) as client:
14 | html = await fetch(client)
15 | print(html)
16 |
17 | loop = asyncio.get_event_loop()
18 |
19 | start = datetime.now()
20 | loop.run_until_complete(main())
21 | end = datetime.now()
22 |
23 |
24 | print("aiohttp版爬虫花费时间为:")
25 | print(end - start)
--------------------------------------------------------------------------------
/day-102/aiohttp_header.py:
--------------------------------------------------------------------------------
1 | import aiohttp
2 | import asyncio
3 | from datetime import datetime
4 |
5 |
6 | async def fetch(client):
7 | headers = {'content-type': 'application/json', 'User-Agent': 'Python/3.8 aiohttp/3.8.2'}
8 | async with client.get('http://httpbin.org/get',headers=headers) as resp:
9 | return await resp.text()
10 |
11 |
12 | async def main():
13 | async with aiohttp.ClientSession() as client:
14 | html = await fetch(client)
15 | print(html)
16 |
17 | loop = asyncio.get_event_loop()
18 |
19 | start = datetime.now()
20 | loop.run_until_complete(main())
21 | end = datetime.now()
22 |
23 |
24 | print("aiohttp版爬虫花费时间为:")
25 | print(end - start)
--------------------------------------------------------------------------------
/day-102/aiohttp_json.py:
--------------------------------------------------------------------------------
1 | import aiohttp
2 | import asyncio
3 | from datetime import datetime
4 |
5 |
6 | async def fetch(client):
7 | async with client.get('http://httpbin.org/get') as resp:
8 | return await resp.json()
9 |
10 |
11 | async def main():
12 | async with aiohttp.ClientSession() as client:
13 | html = await fetch(client)
14 | print(html)
15 |
16 | loop = asyncio.get_event_loop()
17 |
18 | start = datetime.now()
19 | loop.run_until_complete(main())
20 | end = datetime.now()
21 |
22 |
23 | print("aiohttp版爬虫花费时间为:")
24 | print(end - start)
25 |
--------------------------------------------------------------------------------
/day-102/aiohttp_params.py:
--------------------------------------------------------------------------------
1 | import aiohttp
2 | import asyncio
3 | from datetime import datetime
4 |
5 |
6 | async def fetch(client):
7 | #params = {"a": 1,"b": 2}
8 | #params = [('a', 1), ('b', 2)]
9 | async with client.get('http://httpbin.org/get',params='q=aiohttp+python&a=1') as resp:
10 | return await resp.text()
11 |
12 |
13 | async def main():
14 | async with aiohttp.ClientSession() as client:
15 | html = await fetch(client)
16 | print(html)
17 |
18 | loop = asyncio.get_event_loop()
19 |
20 | start = datetime.now()
21 | loop.run_until_complete(main())
22 | end = datetime.now()
23 |
24 |
25 | print("aiohttp版爬虫花费时间为:")
26 | print(end - start)
--------------------------------------------------------------------------------
/day-102/aiohttp_post.py:
--------------------------------------------------------------------------------
1 | import aiohttp
2 | import asyncio
3 | from datetime import datetime
4 |
5 |
6 | async def fetch(client):
7 | data = {'a': '1', 'b': '2'}
8 | async with client.post('http://httpbin.org/post', data = data) as resp:
9 | return await resp.text()
10 |
11 |
12 | async def main():
13 | async with aiohttp.ClientSession() as client:
14 | html = await fetch(client)
15 | print(html)
16 |
17 | loop = asyncio.get_event_loop()
18 |
19 | start = datetime.now()
20 | loop.run_until_complete(main())
21 | end = datetime.now()
22 |
23 |
24 | print("aiohttp版爬虫花费时间为:")
25 | print(end - start)
--------------------------------------------------------------------------------
/day-102/aiohttp_timeout.py:
--------------------------------------------------------------------------------
1 | import aiohttp
2 | import asyncio
3 | from datetime import datetime
4 |
5 |
6 | async def fetch(client):
7 | async with client.get('http://httpbin.org/get', timeout=60) as resp:
8 | return await resp.text()
9 |
10 |
11 | async def main():
12 | async with aiohttp.ClientSession() as client:
13 | html = await fetch(client)
14 | print(html)
15 |
16 | loop = asyncio.get_event_loop()
17 |
18 | start = datetime.now()
19 | loop.run_until_complete(main())
20 | end = datetime.now()
21 |
22 |
23 | print("aiohttp版爬虫花费时间为:")
24 | print(end - start)
--------------------------------------------------------------------------------
/day-102/requests_many.py:
--------------------------------------------------------------------------------
1 | import requests
2 | from datetime import datetime
3 |
4 |
5 | def fetch(url):
6 | r = requests.get(url)
7 | print(r.text)
8 |
9 | start = datetime.now()
10 |
11 | for i in range(30):
12 | fetch('http://httpbin.org/get')
13 |
14 | end = datetime.now()
15 |
16 | print("requests版爬虫花费时间为:")
17 | print(end - start)
18 |
--------------------------------------------------------------------------------
/day-103-01/2.1-示例1.py:
--------------------------------------------------------------------------------
1 | # 定义一个 StringIO 对象,写入并读取其在内存中的内容
2 | from io import StringIO
3 |
4 | f = StringIO()
5 |
6 | f.write('Python-100')
7 | str = f.getvalue()
8 | print('写入内存中的字符串为:%s' %str)
9 |
10 | f.write('\n') # 追加写入内容
11 | f.write('坚持100天')
12 | str = f.getvalue() # getvalue() 可以读取到 StringIO 中的所有内容
13 | print('写入内存中的字符串为:\n%s' %str)
14 |
15 | f.close() # 释放内存中的数据,后续不可再对该 StringIO 进行内容的读写操作
16 |
17 | # 输出结果
18 | # 写入内存中的字符串为:
19 | # Python-100
20 | # 写入内存中的字符串为:
21 | # Python-100
22 | # 坚持100天
--------------------------------------------------------------------------------
/day-103-01/2.1-示例2.py:
--------------------------------------------------------------------------------
1 | # 当然也可以用 read()、readline() 等来读取 StringIO 中写入的字符串
2 |
3 | from io import StringIO
4 |
5 | str = 'Python-100' + '\n' + '坚持100天'
6 |
7 | f = StringIO(str)
8 |
9 | currentStr = f.read()
10 | print('写入内存中的字符串为:\n%s' %currentStr)
11 |
12 | f.close()
--------------------------------------------------------------------------------
/day-103-01/2.2-示例.py:
--------------------------------------------------------------------------------
1 | # 定义一个 BytesIO 对象,写入并读取其在内存中的内容
2 |
3 | from io import BytesIO
4 |
5 | str = 'Python-100' + '\n' + '坚持100天'
6 |
7 | f = BytesIO(str.encode('utf-8'))
8 |
9 | print('写入内存的字节为:%s' %f.getvalue())
10 |
11 | print('字节解码后内容为:\n%s' %f.getvalue().decode('utf-8'))
--------------------------------------------------------------------------------
/day-103/excel_u.py:
--------------------------------------------------------------------------------
1 | # excel_u.py
2 |
3 | # 导入相应模块
4 | import xlrd
5 | from xlutils.copy import copy
6 |
7 | # 打开 excel 文件
8 | readbook = xlrd.open_workbook("test_w.xls")
9 |
10 | # 复制一份
11 | wb = copy(readbook)
12 |
13 | # 选取第一个表单
14 | sh1 = wb.get_sheet(0)
15 |
16 | # 在第四行新增写入数据
17 | sh1.write(3, 0, '王亮')
18 | sh1.write(3, 1, 59)
19 |
20 | # 选取第二个表单
21 | sh1 = wb.get_sheet(1)
22 |
23 | # 替换总成绩数据
24 | sh1.write(1, 0, 246.5)
25 |
26 | # 保存
27 | wb.save('test_w1.xls')
--------------------------------------------------------------------------------
/day-103/excel_w.py:
--------------------------------------------------------------------------------
1 | import xlwt
2 |
3 | # 创建 xls 文件对象
4 | wb = xlwt.Workbook()
5 |
6 | # 新增两个表单页
7 | sh1 = wb.add_sheet('成绩')
8 | sh2 = wb.add_sheet('汇总')
9 |
10 | # 然后按照位置来添加数据,第一个参数是行,第二个参数是列
11 | sh1.write(0, 0, '姓名')
12 | sh1.write(0, 1, '成绩')
13 | sh1.write(1, 0, '张三')
14 | sh1.write(1, 1, 88)
15 | sh1.write(2, 0, '李四')
16 | sh1.write(2, 1, 99.5)
17 |
18 | sh2.write(0, 0, '总分')
19 | sh2.write(1, 0, 187.5)
20 |
21 | # 最后保存文件即可
22 | wb.save('test_w.xls')
--------------------------------------------------------------------------------
/day-104/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-104/__init__.py
--------------------------------------------------------------------------------
/day-104/test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1001
5 | 张三
6 | 22
7 | 男
8 |
9 |
10 | 1002
11 | 李四
12 | 21
13 | 女
14 |
15 |
--------------------------------------------------------------------------------
/day-105/python_install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-105/python_install.png
--------------------------------------------------------------------------------
/day-105/word1.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-105/word1.docx
--------------------------------------------------------------------------------
/day-105/word2.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-105/word2.docx
--------------------------------------------------------------------------------
/day-106/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-106/__init__.py
--------------------------------------------------------------------------------
/day-107-csv/1-示例1.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
3 | A = np.mat(data, int)
4 | print(A, type(A))
--------------------------------------------------------------------------------
/day-107-csv/1-示例2.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A = np.mat(np.zeros((3, 3)), int)
3 | print(A)
--------------------------------------------------------------------------------
/day-107-csv/1-示例3.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A = np.mat(np.ones((3, 3)))
3 | print(A)
--------------------------------------------------------------------------------
/day-107-csv/1-示例4.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A = np.mat(np.eye(3, 3), int)
3 | print(A)
--------------------------------------------------------------------------------
/day-107-csv/1-示例5.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A = np.mat(np.diag([1, 2, 3]), int)
3 | print(A)
--------------------------------------------------------------------------------
/day-107-csv/1-示例6.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A = np.mat(np.full((3, 3), 100), int)
3 | print(A)
--------------------------------------------------------------------------------
/day-107-csv/2.1-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A = np.mat(np.full((3, 3), 100), int)
3 | B = np.mat(np.full((3, 3), 200), int)
4 | print(A+B)
5 | print(A-B)
--------------------------------------------------------------------------------
/day-107-csv/2.2-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | a = 0.1
3 | A = np.mat(np.full((3, 3), 100), int)
4 | print(a*A)
--------------------------------------------------------------------------------
/day-107-csv/2.3-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A = np.mat(np.full((2, 3), 10), int)
3 | B = np.mat(np.full((3, 3), 10), int)
4 | print(A*B) # 求矩阵相乘形式一
5 | print(A.dot(B)) # 求矩阵相乘形式二
6 | print(np.dot(A, B)) # 求矩阵相乘形式三
--------------------------------------------------------------------------------
/day-107-csv/2.4-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | data = [[1,2,3],[4,5,6],[7,8,9]]
3 | A = np.mat(data, int)
4 | print(A.T)
--------------------------------------------------------------------------------
/day-107-csv/2.5-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | data = [[1, 2], [3, 4]]
3 | A = np.mat(data, int)
4 | print(A.I)
--------------------------------------------------------------------------------
/day-107-csv/2.6-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A = np.mat([[1, 2],[3, 4]], int)
3 | det = np.linalg.det(A)
4 | print(det)
--------------------------------------------------------------------------------
/day-107-csv/2.7-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A = np.mat([[1, 2],[3, 4]], int)
3 | rank = np.linalg.matrix_rank(A)
4 | print(rank)
--------------------------------------------------------------------------------
/day-107-csv/2.8-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A = np.mat([[1, 2],[3, 4]], int)
3 | value, vector = np.linalg.eig(A)
4 | print(value)
5 | print(vector)
--------------------------------------------------------------------------------
/day-107-csv/2.9-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A = np.mat([[1, 1, 1], [3, 1, 4], [8, 9, 5]], int)
3 | b = np.mat([[3], [8], [22]], int)
4 | x = np.linalg.solve(A,b)
5 | print(x)
--------------------------------------------------------------------------------
/day-107/pdfminer.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-107/pdfminer.pdf
--------------------------------------------------------------------------------
/day-108-csv/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-108-csv/__init__.py
--------------------------------------------------------------------------------
/day-108-csv/test.csv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-108-csv/test.csv
--------------------------------------------------------------------------------
/day-108/1-示例1.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A_mat = np.mat([[1, 2],[3, 4]], int)
3 | A_array = np.array([[1, 2],[3, 4]])
4 | print(A_mat, type(A_mat))
5 | print(A_array, type(A_array))
--------------------------------------------------------------------------------
/day-108/1-示例2.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A_mat = np.mat([[1, 2],[3, 4]], int)
3 | A_array = np.array(A_mat)
4 | print(A_mat, type(A_mat))
5 | print(A_array, type(A_array))
--------------------------------------------------------------------------------
/day-108/1-示例3.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A_array = np.array([[1, 2],[3, 4]])
3 | A_mat = np.mat(A_array, int)
4 | print(A_mat, type(A_mat))
5 | print(A_array, type(A_array))
--------------------------------------------------------------------------------
/day-108/2.1-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A_mat = np.mat([[1, 2],[3, 4]], int)
3 | B_mat = np.mat([[1, 2],[3, 4]], int)
4 | A_array = np.array([[1, 2],[3, 4]])
5 | B_array = np.array([[1, 2],[3, 4]])
6 | print(A_mat + B_mat)
7 | print(A_array + B_array)
8 |
9 | C_array = np.array([[1, 2]])
10 | C_mat = np.mat([[1, 2]], int)
11 | print(A_array + C_array)
12 | print(A_mat + C_mat)
--------------------------------------------------------------------------------
/day-108/2.10-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A_mat = np.mat([[1, 2],[3, 4]], int)
3 | A_array = np.array([[1, 2],[3, 4]])
4 |
5 | A_mix = A_mat + A_array
6 | print(A_mix, type(A_mix))
7 |
8 | A_array = np.array([1, 2])
9 | A_mix = A_mat + A_array
10 | print(A_mix, type(A_mix))
--------------------------------------------------------------------------------
/day-108/2.2-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | a = 0.1
3 | A_mat = np.mat(np.full((3, 3), 100), int)
4 | A_array = np.full((3, 3), 100)
5 | print(a*A_mat)
6 | print(a*A_array)
--------------------------------------------------------------------------------
/day-108/2.3-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A_mat = np.mat(np.full((3, 3), 100), int)
3 | A_array = np.full((3, 3), 100)
4 |
5 | print(A_mat*A_mat) # 点乘方式一
6 | print(A_array*A_array)
7 |
8 | print(A_mat.dot(A_mat)) # 点乘方式二
9 | print(A_array.dot(A_array))
--------------------------------------------------------------------------------
/day-108/2.4-示例.py:
--------------------------------------------------------------------------------
1 | A_mat = np.mat([[1, 2],[3, 4]], int)
2 | A_array = np.array([[1, 2],[3, 4]])
3 |
4 | print(A_mat.T)
5 | print(A_array.T)
--------------------------------------------------------------------------------
/day-108/2.5-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A_mat = np.mat([[1, 2],[3, 4]], int)
3 | A_array = np.array([[1, 2],[3, 4]])
4 |
5 | print(A_mat.I)
6 | print(np.linalg.inv(A_array))
7 | # print(A_array.I)
--------------------------------------------------------------------------------
/day-108/2.6-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A_mat = np.mat([[1, 2],[3, 4]], int)
3 | A_array = np.array([[1, 2],[3, 4]])
4 |
5 | print(np.linalg.det(A_mat))
6 | print(np.linalg.det(A_array))
--------------------------------------------------------------------------------
/day-108/2.7-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A_mat = np.mat(np.eye(3, 3), int)
3 | A_array = np.eye(3, 3)
4 |
5 | print(np.linalg.matrix_rank(A_mat))
6 | print(np.linalg.matrix_rank(A_array))
--------------------------------------------------------------------------------
/day-108/2.8-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A_mat = np.mat([[1, 2],[3, 4]], int)
3 | value, vector = np.linalg.eig(A_mat)
4 | print(value)
5 | print(vector)
6 |
7 | A_array = np.array([[1, 2],[3, 4]])
8 | value, vector = np.linalg.eig(A_array)
9 | print(value)
10 | print(vector)
--------------------------------------------------------------------------------
/day-108/2.9-示例.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | A_mat = np.mat([[1, 1, 1], [3, 1, 4], [8, 9, 5]], int)
3 | b_mat = np.mat([[3], [8], [22]], int)
4 | x = np.linalg.solve(A_mat, b_mat)
5 | print(x)
6 |
7 | A_array = np.array([[1, 1, 1], [3, 1, 4], [8, 9, 5]])
8 | b_array = np.array([[3], [8], [22]])
9 | x = np.linalg.solve(A_array, b_array)
10 | print(x)
--------------------------------------------------------------------------------
/day-110/gc_ref_count1.py:
--------------------------------------------------------------------------------
1 | import os
2 | import psutil
3 |
4 |
5 | # 打印 python 程序占用的内存大小
6 | def print_memory_info(name):
7 | pid = os.getpid()
8 | p = psutil.Process(pid)
9 |
10 | info = p.memory_full_info()
11 | MB = 1024 * 1024
12 | memory = info.uss / MB
13 | print('%s used %d MB' % (name, memory))
14 |
15 |
16 | def foo():
17 | print_memory_info("foo start")
18 | length = 1000 * 1000
19 | list = [i for i in range(length)]
20 | print_memory_info("foo end")
21 |
22 |
23 | foo()
24 | print_memory_info("main end")
25 |
--------------------------------------------------------------------------------
/day-110/gc_ref_count2.py:
--------------------------------------------------------------------------------
1 | import os
2 | import psutil
3 |
4 |
5 | # 打印 python 程序占用的内存大小
6 | def print_memory_info(name):
7 | pid = os.getpid()
8 | p = psutil.Process(pid)
9 |
10 | info = p.memory_full_info()
11 | MB = 1024 * 1024
12 | memory = info.uss / MB
13 | print('%s used %d MB' % (name, memory))
14 |
15 |
16 | def foo():
17 | print_memory_info("foo start")
18 | length = 1000 * 1000
19 | list = [i for i in range(length)]
20 | print_memory_info("foo end")
21 | return list
22 |
23 |
24 | list = foo()
25 | print_memory_info("main end")
26 |
--------------------------------------------------------------------------------
/day-110/gc_ref_count3.py:
--------------------------------------------------------------------------------
1 | import os
2 | import psutil
3 |
4 |
5 | # 打印 python 程序占用的内存大小
6 | def print_memory_info(name):
7 | pid = os.getpid()
8 | p = psutil.Process(pid)
9 |
10 | info = p.memory_full_info()
11 | MB = 1024 * 1024
12 | memory = info.uss / MB
13 | print('%s used %d MB' % (name, memory))
14 |
15 |
16 | def foo():
17 | print_memory_info("foo start")
18 | length = 1000 * 1000
19 | list_a = [i for i in range(length)]
20 | list_b = [i for i in range(length)]
21 | list_a.append(list_b)
22 | list_b.append(list_a)
23 | print_memory_info("foo end")
24 | return list
25 |
26 |
27 | foo()
28 | print_memory_info("main end")
29 |
--------------------------------------------------------------------------------
/day-111/param_demo1.py:
--------------------------------------------------------------------------------
1 | def sayHello(name): # name 为形式参数
2 | print("Hello %s" % name)
3 |
4 |
5 | name = "hanmeimei" # 实际参数
6 | sayHello(name)
7 |
8 | def swap(a, b):
9 | a, b = b, a
10 | print("in swap a = %d and b = %d " % (a, b))
11 |
12 |
13 | a = 100
14 | b = 200
15 | swap(a, b)
16 | print("in main a = %d and b = %d " % (a, b))
--------------------------------------------------------------------------------
/day-111/param_demo2.py:
--------------------------------------------------------------------------------
1 | def swap(list):
2 | list.append(4)
3 | print("in swap list is %s " % list)
4 |
5 |
6 | list_x = [1, 2, 3]
7 | swap(list_x)
8 | print("in main list is %s " % list_x)
9 |
--------------------------------------------------------------------------------
/day-111/param_demo3.py:
--------------------------------------------------------------------------------
1 | def swap(list):
2 | list = list + [4]
3 | print("in swap list is %s " % list)
4 |
5 |
6 | list_x = [1, 2, 3]
7 | swap(list_x)
8 | print("in main list is %s " % list_x)
9 |
--------------------------------------------------------------------------------
/day-112/MonteCarlo.py:
--------------------------------------------------------------------------------
1 | import random
2 |
3 |
4 | def solve_pi(repeat = 20000) -> float:
5 | '''
6 | :param repeat: integral
7 |
8 | :return: float
9 | '''
10 | count = 0
11 | for i in range(repeat):
12 | x = random.random()
13 | y = random.random()
14 | if x*x + y*y < 1.0:
15 | count += 1
16 |
17 | ratio = count / repeat
18 | PI = 4 * ratio
19 | return PI
20 |
21 | if __name__ == "__main__":
22 | repeat = int(input("请输入实验次数:"))
23 | print(solve_pi(repeat))
24 |
--------------------------------------------------------------------------------
/day-112/MonteCarlo_integral.py:
--------------------------------------------------------------------------------
1 | import random
2 |
3 |
4 | def solve_integral(repeat = 20000) -> float:
5 | '''
6 | :param repeat: integral
7 |
8 | :return: float
9 | '''
10 |
11 | count = 0
12 | for i in range(repeat):
13 | x = random.random()
14 | y = random.random()
15 | if y > x*x:
16 | count += 1
17 |
18 | ratio = count / repeat
19 | integral = ratio * 1
20 | return integral
21 |
22 | if __name__ == "__main__":
23 | repeat = int(input("请输入实验次数:"))
24 | print(solve_integral(repeat))
25 |
--------------------------------------------------------------------------------
/day-112/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-112/__init__.py
--------------------------------------------------------------------------------
/day-115/data.csv:
--------------------------------------------------------------------------------
1 | 天气,温度,湿度,风力,结果
2 | 多云,热,高,强,是
3 | 多云,热,高,强,否
4 | 多云,冷,高,弱,否
5 | 多云,冷,高,弱,否
6 | 多云,冷,低,弱,是
7 | 多云,热,低,中,是
8 | 小雨,热,高,弱,否
9 | 小雨,冷,高,弱,否
10 | 小雨,热,低,中,是
11 | 小雨,低,低,强,否
12 |
--------------------------------------------------------------------------------
/day-117/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-117/__init__.py
--------------------------------------------------------------------------------
/day-118/object_demo.py:
--------------------------------------------------------------------------------
1 | a = 'red'
2 | b = 'red'
3 | print(a == b)
4 |
5 | print(a is b)
6 |
7 | a = 256
8 | b = 256
9 |
10 | print(f'id(a) is :{id(a)}')
11 | print(f'id(b) is :{id(b)}')
12 | print(a==b)
13 | print(a is b)
14 |
15 | a = 257
16 | b = 257
17 |
18 | print(f'id(a) is :{id(a)}')
19 | print(f'id(b) is :{id(b)}')
20 | print(a==b)
21 | print(a is b)
22 |
23 | a = 25700
24 | b = 25700
25 | print(a is b)
--------------------------------------------------------------------------------
/day-118/object_demo2.py:
--------------------------------------------------------------------------------
1 | a = [1, 'hello', [1, 2]]
2 | b = list(a)
3 |
4 | a[0] = 100
5 | a[2][0] = 100
6 |
7 | print(a)
8 | print(b)
9 | print(a is b)
10 |
11 | a = [1, 2, 3]
12 | b = a[:]
13 | print(a == b)
14 | print(a is b)
15 |
16 |
17 | a = (1, 2, 3)
18 | b = tuple(a)
19 | print(a == b)
20 | print(a is b)
21 |
22 |
23 | import copy
24 |
25 | a = [1, 'hello', [1,2]]
26 | b = copy.deepcopy(a)
27 |
28 | a[0] = 100
29 | a[2][0] = 100
30 | print(a)
31 | print(b)
32 |
33 | a = (1,2,3)
34 | b = copy.deepcopy(a)
35 | print(a is b)
36 |
37 | a = (1,2,[1,2])
38 | b = copy.deepcopy(a)
39 | print(a is b)
40 |
41 | a[2][0] = 100
42 | print(a)
43 | print(b)
44 |
--------------------------------------------------------------------------------
/day-120/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-120/__init__.py
--------------------------------------------------------------------------------
/day-122/app.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, request
2 | from config import config
3 | from route import route_bp
4 | from model import init_app
5 |
6 | def create_app(config_name='default'):
7 | app = Flask(__name__)
8 | app.config.from_object(config[config_name])
9 | init_app(app)
10 | app.register_blueprint(route_bp)
11 | return app
12 |
13 |
--------------------------------------------------------------------------------
/day-122/model.py:
--------------------------------------------------------------------------------
1 | from flask_sqlalchemy import SQLAlchemy
2 | import click
3 | from flask.cli import with_appcontext
4 |
5 | db = SQLAlchemy()
6 |
7 | def init_db():
8 | db.drop_all()
9 | db.create_all()
10 |
11 | def init_app(app):
12 | db.init_app(app)
13 | app.cli.add_command(init_db_command)
14 |
15 | class User(db.Model):
16 | id = db.Column(db.Integer, primary_key=True, autoincrement=True)
17 | name = db.Column(db.String(64), unique= True, index= True)
18 |
19 | @click.command("init-db")
20 | @with_appcontext
21 | def init_db_command():
22 | """Clear existing data and create new tables."""
23 | init_db()
24 | click.echo("Initialized the database.")
--------------------------------------------------------------------------------
/day-123/TestProject/TestProject/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/TestProject/__init__.py
--------------------------------------------------------------------------------
/day-123/TestProject/TestProject/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/TestProject/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-123/TestProject/TestProject/__pycache__/settings.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/TestProject/__pycache__/settings.cpython-37.pyc
--------------------------------------------------------------------------------
/day-123/TestProject/TestProject/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/TestProject/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/day-123/TestProject/TestProject/__pycache__/wsgi.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/TestProject/__pycache__/wsgi.cpython-37.pyc
--------------------------------------------------------------------------------
/day-123/TestProject/TestProject/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for TestProject project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TestProject.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/day-123/TestProject/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/db.sqlite3
--------------------------------------------------------------------------------
/day-123/TestProject/polls/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/polls/__init__.py
--------------------------------------------------------------------------------
/day-123/TestProject/polls/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/polls/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-123/TestProject/polls/__pycache__/admin.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/polls/__pycache__/admin.cpython-37.pyc
--------------------------------------------------------------------------------
/day-123/TestProject/polls/__pycache__/apps.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/polls/__pycache__/apps.cpython-37.pyc
--------------------------------------------------------------------------------
/day-123/TestProject/polls/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/polls/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/day-123/TestProject/polls/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/polls/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/day-123/TestProject/polls/__pycache__/views.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/polls/__pycache__/views.cpython-37.pyc
--------------------------------------------------------------------------------
/day-123/TestProject/polls/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from polls.models import Question,Choice
3 |
4 | admin.site.register(Question)
5 | admin.site.register(Choice)
6 |
--------------------------------------------------------------------------------
/day-123/TestProject/polls/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class PollsConfig(AppConfig):
5 | name = 'polls'
6 |
--------------------------------------------------------------------------------
/day-123/TestProject/polls/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/polls/migrations/__init__.py
--------------------------------------------------------------------------------
/day-123/TestProject/polls/migrations/__pycache__/0001_initial.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/polls/migrations/__pycache__/0001_initial.cpython-37.pyc
--------------------------------------------------------------------------------
/day-123/TestProject/polls/migrations/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-123/TestProject/polls/migrations/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-123/TestProject/polls/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | class Question(models.Model):
4 | question_text = models.CharField(max_length=200)
5 | pub_date = models.DateTimeField('发布日期')
6 |
7 |
8 | class Choice(models.Model):
9 | question = models.ForeignKey(Question, on_delete=models.CASCADE)
10 | choice_text = models.CharField(max_length=200)
11 | votes = models.IntegerField(default=0)
12 |
--------------------------------------------------------------------------------
/day-123/TestProject/polls/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/day-123/TestProject/polls/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path('', views.index, name='index'),
7 | path('add', views.add, name='add'),
8 | path('query', views.query, name='query'),
9 | path('update', views.update, name='update'),
10 | path('del', views.delete, name='del'),
11 | ]
12 |
--------------------------------------------------------------------------------
/day-124/TestProject/TestProject/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/TestProject/__init__.py
--------------------------------------------------------------------------------
/day-124/TestProject/TestProject/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/TestProject/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-124/TestProject/TestProject/__pycache__/settings.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/TestProject/__pycache__/settings.cpython-37.pyc
--------------------------------------------------------------------------------
/day-124/TestProject/TestProject/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/TestProject/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/day-124/TestProject/TestProject/__pycache__/wsgi.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/TestProject/__pycache__/wsgi.cpython-37.pyc
--------------------------------------------------------------------------------
/day-124/TestProject/TestProject/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for TestProject project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TestProject.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/day-124/TestProject/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/db.sqlite3
--------------------------------------------------------------------------------
/day-124/TestProject/polls/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/polls/__init__.py
--------------------------------------------------------------------------------
/day-124/TestProject/polls/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/polls/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-124/TestProject/polls/__pycache__/admin.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/polls/__pycache__/admin.cpython-37.pyc
--------------------------------------------------------------------------------
/day-124/TestProject/polls/__pycache__/apps.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/polls/__pycache__/apps.cpython-37.pyc
--------------------------------------------------------------------------------
/day-124/TestProject/polls/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/polls/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/day-124/TestProject/polls/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/polls/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/day-124/TestProject/polls/__pycache__/views.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/polls/__pycache__/views.cpython-37.pyc
--------------------------------------------------------------------------------
/day-124/TestProject/polls/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from polls.models import Question,Choice
3 |
4 | admin.site.register(Question)
5 | admin.site.register(Choice)
6 |
--------------------------------------------------------------------------------
/day-124/TestProject/polls/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class PollsConfig(AppConfig):
5 | name = 'polls'
6 |
--------------------------------------------------------------------------------
/day-124/TestProject/polls/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/polls/migrations/__init__.py
--------------------------------------------------------------------------------
/day-124/TestProject/polls/migrations/__pycache__/0001_initial.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/polls/migrations/__pycache__/0001_initial.cpython-37.pyc
--------------------------------------------------------------------------------
/day-124/TestProject/polls/migrations/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-124/TestProject/polls/migrations/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-124/TestProject/polls/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | class Question(models.Model):
4 | question_text = models.CharField(max_length=200)
5 | pub_date = models.DateTimeField('发布日期')
6 |
7 |
8 | class Choice(models.Model):
9 | question = models.ForeignKey(Question, on_delete=models.CASCADE)
10 | choice_text = models.CharField(max_length=200)
11 | votes = models.IntegerField(default=0)
12 |
--------------------------------------------------------------------------------
/day-124/TestProject/polls/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/day-124/TestProject/polls/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path('', views.index, name='index'),
7 | path('add', views.add, name='add'),
8 | path('query', views.query, name='query'),
9 | path('update', views.update, name='update'),
10 | path('del', views.delete, name='del'),
11 | ]
12 |
--------------------------------------------------------------------------------
/day-124/TestProject/templates/common.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | 公共页面
4 |
5 |
6 |
7 | 你好{{ name }} ,这是一个公共页面!
8 | {% block mainbody %}
9 | 原始页
10 | {% endblock %}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/day-124/TestProject/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "common.html" %}
2 |
3 | {% block mainbody %}
4 | 这里继承了 common.html 模板!
5 | {% endblock %}
6 |
--------------------------------------------------------------------------------
/day-125/project/__init__.py:
--------------------------------------------------------------------------------
1 | from flask import Flask
2 |
3 | from .config import config
4 | from . import models, routes
5 |
6 | def create_app(config_name='default'):
7 | app = Flask(__name__)
8 | app.config.from_object(config[config_name])
9 | config[config_name].init_app(app)
10 |
11 | models.init_app(app)
12 | routes.init_app(app)
13 |
14 | return app
15 |
--------------------------------------------------------------------------------
/day-125/project/data-dev.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-125/project/data-dev.db
--------------------------------------------------------------------------------
/day-125/project/data-test.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-125/project/data-test.db
--------------------------------------------------------------------------------
/day-125/project/forms/myform.py:
--------------------------------------------------------------------------------
1 | from flask_wtf import FlaskForm
2 | from wtforms import StringField, DateField, TextAreaField
3 | from wtforms.validators import DataRequired, InputRequired
4 |
5 | class MyForm(FlaskForm):
6 | name = StringField(label='Name', validators=[InputRequired()])
7 | birthday = DateField(label='Birthday', format="%Y-%m-%d", validators=[DataRequired('Invalided Date'),InputRequired()])
8 | about = TextAreaField(label='About')
--------------------------------------------------------------------------------
/day-125/project/models/profile.py:
--------------------------------------------------------------------------------
1 | from . import db
2 |
3 | class Profile(db.Model):
4 | id = db.Column(db.Integer, primary_key=True)
5 | name = db.Column(db.String(20))
6 | birthday = db.Column(db.Date())
7 | createtime = db.Column(db.DateTime())
8 | about = db.Column(db.Text())
--------------------------------------------------------------------------------
/day-125/project/models/user.py:
--------------------------------------------------------------------------------
1 | from . import db
2 |
3 | class User(db.Model):
4 | id = db.Column(db.Integer, primary_key=True)
5 | name = db.Column(db.String(64), unique= True, index= True)
--------------------------------------------------------------------------------
/day-125/project/routes/__init__.py:
--------------------------------------------------------------------------------
1 | from .home import home_bp
2 | from .profile import profile_bp
3 |
4 | def init_app(app):
5 | app.register_blueprint(home_bp)
6 | app.register_blueprint(profile_bp)
--------------------------------------------------------------------------------
/day-125/project/routes/home.py:
--------------------------------------------------------------------------------
1 | from flask import Blueprint
2 | from flask import render_template
3 |
4 | home_bp = Blueprint('home_bp', __name__)
5 | print("routes/home.py __name__ is :", __name__)
6 | @home_bp.route('/', methods=['GET', 'POST'])
7 | def index():
8 | return render_template('index.html')
--------------------------------------------------------------------------------
/day-125/project/templates/createprofile.html:
--------------------------------------------------------------------------------
1 | {% macro render_field(field) %}
2 | {{ field.label }}:
3 | {{ field(**kwargs)|safe }}
4 | {% if field.errors %}
5 |
6 | {% for error in field.errors %}
7 | {{ error }}
8 | {% endfor %}
9 |
10 | {% endif %}
11 |
12 | {% endmacro %}
13 |
14 |
--------------------------------------------------------------------------------
/day-125/project/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Flask Project Structure
5 |
6 |
7 | Welcome!
8 |
9 | 创建配置
10 |
11 |
--------------------------------------------------------------------------------
/day-125/project/templates/profile.html:
--------------------------------------------------------------------------------
1 | {{ profile.name }}'s Info
2 | Name:
3 | {{ profile.name }}
4 | Birthday:
5 | {{ profile.birthday }}
6 | About:
7 | {{ profile.about }}
--------------------------------------------------------------------------------
/day-126/2.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-126/2.py
--------------------------------------------------------------------------------
/day-127/2.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-127/2.py
--------------------------------------------------------------------------------
/day-127/5.py:
--------------------------------------------------------------------------------
1 | import seaborn as sns
2 | import matplotlib.pyplot as plt
3 | sns.set(style="darkgrid")
4 |
5 | iris = sns.load_dataset("iris")
6 | sns.catplot(data=iris, orient="h", kind="box")
7 |
8 | sns.violinplot(x=iris.species, y=iris.sepal_length)
9 |
10 | f, ax = plt.subplots(figsize=(7, 3))
11 | sns.countplot(y="deck", data=titanic, color="c")
--------------------------------------------------------------------------------
/day-127/6.py:
--------------------------------------------------------------------------------
1 | import seaborn as sns
2 | import matplotlib.pyplot as plt
3 | sns.set(style="darkgrid")
4 |
5 | tips = sns.load_dataset("tips")
6 | sns.catplot(x="day", y="total_bill", hue="smoker",
7 | col="time", aspect=.6,
8 | kind="swarm", data=tips)
9 |
10 | tips = sns.load_dataset("titanic")
11 | g = sns.catplot(x="fare", y="survived", row="class",
12 | kind="box", orient="h", height=1.5, aspect=4,
13 | data=titanic.query("fare > 0"))
14 | g.set(xscale="log")
--------------------------------------------------------------------------------
/day-128/2.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-128/2.py
--------------------------------------------------------------------------------
/day-128/4.py:
--------------------------------------------------------------------------------
1 | import seaborn as sns
2 | import matplotlib.pyplot as plt
3 | from scipy import stats
4 | sns.set(color_codes=True)
5 |
6 | iris = sns.load_dataset("iris")
7 | sns.pairplot(iris)
8 |
9 | g = sns.PairGrid(iris)
10 | g.map_diag(sns.kdeplot)
11 | g.map_offdiag(sns.kdeplot, n_levels=6)
--------------------------------------------------------------------------------
/day-130/myproject/__init__.py:
--------------------------------------------------------------------------------
1 | from flask import Flask
2 | from .config import config
3 |
4 | def create_app(config_name='default'):
5 | app = Flask(__name__)
6 | app.config.from_object(config[config_name])
7 | config[config_name].init_app(app)
8 |
9 | @app.route("/")
10 | def index():
11 | return "Hello world!"
12 |
13 | return app
14 |
--------------------------------------------------------------------------------
/day-130/myproject/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-130/myproject/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/day-130/myproject/__pycache__/config.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/day-130/myproject/__pycache__/config.cpython-37.pyc
--------------------------------------------------------------------------------
/day-130/requirements.txt:
--------------------------------------------------------------------------------
1 | astroid==2.3.3
2 | Click==7.0
3 | Flask==1.1.1
4 | Flask-SQLAlchemy==2.4.1
5 | Flask-WTF==0.14.3
6 | isort==4.3.21
7 | itsdangerous==1.1.0
8 | Jinja2==2.11.1
9 | lazy-object-proxy==1.4.3
10 | MarkupSafe==1.1.1
11 | mccabe==0.6.1
12 | pylint==2.4.4
13 | six==1.14.0
14 | SQLAlchemy==1.3.13
15 | typed-ast==1.4.1
16 | Werkzeug==1.0.0
17 | wrapt==1.11.2
18 | WTForms==2.2.1
19 |
--------------------------------------------------------------------------------
/day-130/run.py:
--------------------------------------------------------------------------------
1 | from myproject import create_app
2 | import os
3 |
4 | env_dist = os.environ
5 |
6 | config = env_dist.get('FLASK_APP', 'default')
7 | app = create_app(config)
--------------------------------------------------------------------------------
/day-130/uwsgi.ini:
--------------------------------------------------------------------------------
1 | [uwsgi]
2 | master = true
3 | http=:5000
4 | chdir = %d
5 | wsgi-file=%drun.py
6 | home=/home/alisx/Project/Article/python100/.venv
7 | callable=app
8 | processes=4
9 | threads=2
10 | buffer-size = 65536
11 | vacuum=true
12 | pidfile =%duwsgi.pid
--------------------------------------------------------------------------------
/day-130/uwsgi.pid:
--------------------------------------------------------------------------------
1 | 12510
2 |
--------------------------------------------------------------------------------
/flask_pyecharts/templates/pyecharts/components.html:
--------------------------------------------------------------------------------
1 | {% import 'macro' as macro %}
2 |
3 |
4 |
5 |
6 | {{ chart.page_title }}
7 |
8 |
9 |
10 | {{ macro.gen_components_content(chart) }}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/flask_pyecharts/templates/pyecharts/nb_components.html:
--------------------------------------------------------------------------------
1 | {% import 'macro' as macro %}
2 |
3 | {% for chart in charts %}
4 | {{ macro.gen_components_content(chart) }}
5 | {% endfor %}
6 |
--------------------------------------------------------------------------------
/flask_pyecharts/templates/pyecharts/nb_jupyter_lab.html:
--------------------------------------------------------------------------------
1 | {% import 'macro' as macro %}
2 |
3 |
4 |
5 |
6 |
7 |
8 | {% for chart in charts %}
9 | {% if chart._component_type in ("table", "image") %}
10 | {{ macro.gen_components_content(chart) }}
11 | {% else %}
12 | {{ macro.render_chart_content(chart) }}
13 | {% endif %}
14 | {% endfor %}
15 |
16 |
17 |
--------------------------------------------------------------------------------
/flask_pyecharts/templates/pyecharts/nb_jupyter_lab_tab.html:
--------------------------------------------------------------------------------
1 | {% import 'macro' as macro %}
2 |
3 |
4 |
5 |
6 |
7 |
8 | {{ macro.generate_tab_css() }}
9 | {{ macro.display_tablinks(charts) }}
10 |
11 | {% for chart in charts %}
12 | {% if chart._component_type in ("table", "image") %}
13 | {{ macro.gen_components_content(chart) }}
14 | {% else %}
15 | {{ macro.render_chart_content(chart) }}
16 | {% endif %}
17 | {% endfor %}
18 | {{ macro.switch_tabs() }}
19 |
20 |
21 |
--------------------------------------------------------------------------------
/flask_pyecharts/templates/pyecharts/nb_jupyter_notebook.html:
--------------------------------------------------------------------------------
1 | {% import 'macro' as macro %}
2 |
3 |
10 |
11 | {% for chart in charts %}
12 | {% if chart._component_type in ("table", "image") %}
13 | {{ macro.gen_components_content(chart) }}
14 | {% else %}
15 |
16 | {% endif %}
17 | {% endfor %}
18 |
19 | {{ macro.render_notebook_charts(charts, libraries) }}
20 |
--------------------------------------------------------------------------------
/flask_pyecharts/templates/pyecharts/nb_nteract.html:
--------------------------------------------------------------------------------
1 | {% import 'macro' as macro %}
2 |
3 |
4 |
5 |
6 | {{ macro.render_chart_dependencies(chart) }}
7 |
8 |
9 | {% for c in chart %}
10 | {{ macro.render_chart_content(c) }}
11 | {% endfor %}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/flask_pyecharts/templates/pyecharts/simple_chart.html:
--------------------------------------------------------------------------------
1 | {% import 'macro' as macro %}
2 |
3 |
4 |
5 |
6 | {{ chart.page_title }}
7 | {{ macro.render_chart_dependencies(chart) }}
8 |
9 |
10 | {{ macro.render_chart_content(chart) }}
11 |
12 |
13 |
--------------------------------------------------------------------------------
/lagou/jobs.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE `jobs` (
2 | `id` int(11) NOT NULL AUTO_INCREMENT,
3 | `positionName` varchar(45) DEFAULT NULL,
4 | `workYear` varchar(45) DEFAULT NULL,
5 | `salary` varchar(45) DEFAULT NULL,
6 | `city` varchar(45) DEFAULT NULL,
7 | `education` varchar(100) DEFAULT NULL,
8 | `positionAdvantage` varchar(100) DEFAULT NULL,
9 | `companyLabelList` varchar(100) DEFAULT NULL,
10 | `financeStage` varchar(45) DEFAULT NULL,
11 | `companySize` varchar(45) DEFAULT NULL,
12 | `industryField` varchar(100) DEFAULT NULL,
13 | `firstType` varchar(100) DEFAULT NULL,
14 | PRIMARY KEY (`id`)
15 | )
16 |
--------------------------------------------------------------------------------
/leetcode-089/leetcode89.py:
--------------------------------------------------------------------------------
1 | from typing import List
2 |
3 | class Solution:
4 | def grayCode(self, n: int) -> List[int]:
5 | res = []
6 | for i in range(1 << n):
7 | res.append((i >> 1) ^ i)
8 | return res
9 |
10 | # Below is testing
11 | obj = Solution()
12 | print(obj.grayCode(2))
--------------------------------------------------------------------------------
/pythondocx/word.py:
--------------------------------------------------------------------------------
1 | from docx import Document
2 | import re
3 |
4 | doc = Document(r"D:\论文.docx")
5 | restr = '"(?:[^"])*"'
6 |
7 | for p in doc.paragraphs:
8 | matchRet = re.findall(restr, p.text)
9 | for r in matchRet:
10 | p.text = p.text.replace(r, '“' + r[1:-1] + '”')
11 | doc.save(r'D:\论文_修正.docx')
--------------------------------------------------------------------------------
/qrcode_demo/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/qrcode_demo/__init__.py
--------------------------------------------------------------------------------
/qrcode_demo/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/qrcode_demo/bg.jpg
--------------------------------------------------------------------------------
/qrcode_demo/gmqr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/qrcode_demo/gmqr.png
--------------------------------------------------------------------------------
/qrcode_demo/gmyqr.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/qrcode_demo/gmyqr.gif
--------------------------------------------------------------------------------
/qrcode_demo/gzh.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/qrcode_demo/gzh.jpg
--------------------------------------------------------------------------------
/qrcode_demo/my.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/qrcode_demo/my.gif
--------------------------------------------------------------------------------
/qrcode_demo/myqr.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/qrcode_demo/myqr.gif
--------------------------------------------------------------------------------
/qrcode_demo/myqr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/qrcode_demo/myqr.png
--------------------------------------------------------------------------------
/qrcode_demo/myqr_demo.py:
--------------------------------------------------------------------------------
1 | from MyQR import myqr
2 |
3 | '''
4 | words:内容
5 | version:容错率
6 | save_name:保存的名字
7 | '''
8 | # myqr.run(words='https://www.baidu.com/',
9 | # version=1,
10 | # save_name='myqr.png')
11 |
12 | '''
13 | picture:生成二维码用到的图片
14 | colorized:False 为黑白,True 为彩色
15 | '''
16 | # myqr.run(words='https://www.baidu.com/',
17 | # version=1,
18 | # picture='bg.jpg',
19 | # colorized=True,
20 | # save_name='pmyqr.png')
21 |
22 | myqr.run(words='https://www.baidu.com/',
23 | version=1,
24 | picture='my.gif',
25 | colorized=True,
26 | save_name='myqr.gif')
27 |
--------------------------------------------------------------------------------
/qrcode_demo/parseqr_demo.py:
--------------------------------------------------------------------------------
1 | import zxing
2 | from MyQR import myqr
3 |
4 | reader = zxing.BarCodeReader()
5 | barcode = reader.decode('gzh.jpg')
6 | # print(str(barcode.parsed))
7 | myqr.run(words=str(barcode.parsed),
8 | version=1,
9 | picture='my.gif',
10 | colorized=True,
11 | save_name='gmyqr.gif')
--------------------------------------------------------------------------------
/qrcode_demo/pmyqr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/qrcode_demo/pmyqr.png
--------------------------------------------------------------------------------
/qrcode_demo/qr.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/qrcode_demo/qr.jpg
--------------------------------------------------------------------------------
/wsfriends/alice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JustDoPython/python-100-day/4e75007195aa4cdbcb899aeb06b9b08996a4606c/wsfriends/alice.png
--------------------------------------------------------------------------------