@@ -40,6 +40,13 @@ msgid ""
4040"shell\n"
4141"0"
4242msgstr ""
43+ ">>> import os\n"
44+ ">>> os.getcwd() # 현재 작업 디렉터리를 돌려줍니다\n"
45+ "'C:\\\\ Python313'\n"
46+ ">>> os.chdir('/server/accesslogs') # Change current working directory\n"
47+ ">>> os.system('mkdir today') # Run the command mkdir in the system "
48+ "shell\n"
49+ "0"
4350
4451#: ../../tutorial/stdlib.rst:23
4552msgid ""
@@ -66,6 +73,11 @@ msgid ""
6673">>> help(os)\n"
6774"<returns an extensive manual page created from the module's docstrings>"
6875msgstr ""
76+ ">>> import os\n"
77+ ">>> dir(os)\n"
78+ "<returns a list of all module functions>\n"
79+ ">>> help(os)\n"
80+ "<returns an extensive manual page created from the module's docstrings>"
6981
7082#: ../../tutorial/stdlib.rst:38
7183msgid ""
@@ -81,6 +93,11 @@ msgid ""
8193">>> shutil.move('/build/executables', 'installdir')\n"
8294"'installdir'"
8395msgstr ""
96+ ">>> import shutil\n"
97+ ">>> shutil.copyfile('data.db', 'archive.db')\n"
98+ "'archive.db'\n"
99+ ">>> shutil.move('/build/executables', 'installdir')\n"
100+ "'installdir'"
84101
85102#: ../../tutorial/stdlib.rst:51
86103msgid "File Wildcards"
@@ -98,38 +115,42 @@ msgid ""
98115">>> glob.glob('*.py')\n"
99116"['primes.py', 'random.py', 'quote.py']"
100117msgstr ""
118+ ">>> import glob\n"
119+ ">>> glob.glob('*.py')\n"
120+ "['primes.py', 'random.py', 'quote.py']"
101121
102122#: ../../tutorial/stdlib.rst:64
103123msgid "Command Line Arguments"
104124msgstr "명령행 인자"
105125
106126#: ../../tutorial/stdlib.rst:66
107- #, fuzzy
108127msgid ""
109128"Common utility scripts often need to process command line arguments. "
110129"These arguments are stored in the :mod:`sys` module's *argv* attribute as"
111130" a list. For instance, let's take the following :file:`demo.py` file::"
112131msgstr ""
113132"일반적인 유틸리티 스크립트는 종종 명령행 인자를 처리해야 할 필요가 있습니다. 이 인자들은 :mod:`sys` 모듈의 *argv* "
114- "어트리뷰트에 리스트로 저장됩니다. 예를 들어, 명령행에서 ``python demo.py one two three`` 를 실행하면 "
115- "다음과 같은 결과가 출력됩니다::"
133+ "어트리뷰트에 리스트로 저장됩니다. 예를 들어, 다음과 같은 :file:`demo.py` 파일을 보겠습니다::"
116134
117135#: ../../tutorial/stdlib.rst:70
118136msgid ""
119137"# File demo.py\n"
120138"import sys\n"
121139"print(sys.argv)"
122140msgstr ""
141+ "# 파일 demo.py\n"
142+ "import sys\n"
143+ "print(sys.argv)"
123144
124145#: ../../tutorial/stdlib.rst:74
125146msgid ""
126147"Here is the output from running ``python demo.py one two three`` at the "
127148"command line::"
128- msgstr ""
149+ msgstr "다음은 명령행에서 ``python demo.py one two three`` 를 실행한 출력입니다:: "
129150
130151#: ../../tutorial/stdlib.rst:77
131152msgid "['demo.py', 'one', 'two', 'three']"
132- msgstr ""
153+ msgstr "['demo.py', 'one', 'two', 'three'] "
133154
134155#: ../../tutorial/stdlib.rst:79
135156msgid ""
@@ -152,6 +173,15 @@ msgid ""
152173"args = parser.parse_args()\n"
153174"print(args)"
154175msgstr ""
176+ "import argparse\n"
177+ "\n"
178+ "parser = argparse.ArgumentParser(\n"
179+ " prog='top',\n"
180+ " description='Show top lines from each file')\n"
181+ "parser.add_argument('filenames', nargs='+')\n"
182+ "parser.add_argument('-l', '--lines', type=int, default=10)\n"
183+ "args = parser.parse_args()\n"
184+ "print(args)"
155185
156186#: ../../tutorial/stdlib.rst:93
157187msgid ""
@@ -182,6 +212,9 @@ msgid ""
182212"\n"
183213"Warning, log file not found starting a new one"
184214msgstr ""
215+ ">>> sys.stderr.write('Warning, log file not found starting a new one\\ n')"
216+ "\n"
217+ "Warning, log file not found starting a new one"
185218
186219#: ../../tutorial/stdlib.rst:110
187220msgid "The most direct way to terminate a script is to use ``sys.exit()``."
@@ -208,6 +241,11 @@ msgid ""
208241">>> re.sub(r'(\\ b[a-z]+) \\ 1', r'\\ 1', 'cat in the the hat')\n"
209242"'cat in the hat'"
210243msgstr ""
244+ ">>> import re\n"
245+ ">>> re.findall(r'\\ bf[a-z]*', 'which foot or hand fell fastest')\n"
246+ "['foot', 'fell', 'fastest']\n"
247+ ">>> re.sub(r'(\\ b[a-z]+) \\ 1', r'\\ 1', 'cat in the the hat')\n"
248+ "'cat in the hat'"
211249
212250#: ../../tutorial/stdlib.rst:128
213251msgid ""
@@ -220,13 +258,14 @@ msgid ""
220258">>> 'tea for too'.replace('too', 'two')\n"
221259"'tea for two'"
222260msgstr ""
261+ ">>> 'tea for too'.replace('too', 'two')\n"
262+ "'tea for two'"
223263
224264#: ../../tutorial/stdlib.rst:138
225265msgid "Mathematics"
226266msgstr "수학"
227267
228268#: ../../tutorial/stdlib.rst:140
229- #, fuzzy
230269msgid ""
231270"The :mod:`math` module gives access to the underlying C library functions"
232271" for floating-point math::"
@@ -240,6 +279,11 @@ msgid ""
240279">>> math.log(1024, 2)\n"
241280"10.0"
242281msgstr ""
282+ ">>> import math\n"
283+ ">>> math.cos(math.pi / 4)\n"
284+ "0.70710678118654757\n"
285+ ">>> math.log(1024, 2)\n"
286+ "10.0"
243287
244288#: ../../tutorial/stdlib.rst:149
245289msgid "The :mod:`random` module provides tools for making random selections::"
@@ -257,6 +301,15 @@ msgid ""
257301">>> random.randrange(6) # random integer chosen from range(6)\n"
258302"4"
259303msgstr ""
304+ ">>> import random\n"
305+ ">>> random.choice(['apple', 'pear', 'banana'])\n"
306+ "'apple'\n"
307+ ">>> random.sample(range(100), 10) # 대체 없는 표본 추출\n"
308+ "[30, 83, 16, 4, 8, 81, 41, 50, 18, 33]\n"
309+ ">>> random.random() # 범위 [0.0, 1.0) 내에서의 임의의 float\n"
310+ "0.17970987693706186\n"
311+ ">>> random.randrange(6) # range(6) 에서 선택된 임의의 정수\n"
312+ "4"
260313
261314#: ../../tutorial/stdlib.rst:161
262315msgid ""
@@ -275,6 +328,14 @@ msgid ""
275328">>> statistics.variance(data)\n"
276329"1.3720238095238095"
277330msgstr ""
331+ ">>> import statistics\n"
332+ ">>> data = [2.75, 1.75, 1.25, 0.25, 0.5, 1.25, 3.5]\n"
333+ ">>> statistics.mean(data)\n"
334+ "1.6071428571428572\n"
335+ ">>> statistics.median(data)\n"
336+ "1.25\n"
337+ ">>> statistics.variance(data)\n"
338+ "1.3720238095238095"
278339
279340#: ../../tutorial/stdlib.rst:173
280341msgid ""
@@ -317,6 +378,25 @@ msgid ""
317378"... \"\"\" )\n"
318379">>> server.quit()"
319380msgstr ""
381+ ">>> from urllib.request import urlopen\n"
382+ ">>> with urlopen('http://worldtimeapi.org/api/timezone/etc/UTC.txt') as "
383+ "response:\n"
384+ "... for line in response:\n"
385+ "... line = line.decode() # bytes 를 str 로 변환합니다\n"
386+ "... if line.startswith('datetime'):\n"
387+ "... print(line.rstrip()) # 후행 줄 넘김을 제거합니다\n"
388+ "...\n"
389+ "datetime: 2022-01-01T01:36:47.689215+00:00\n"
390+ "\n"
391+ ">>> import smtplib\n"
392+ ">>> server = smtplib.SMTP('localhost')\n"
393+ 394+ "... \"\"\" To: [email protected] \n" 395+ 396+ "...\n"
397+ "... Beware the Ides of March.\n"
398+ "... \"\"\" )\n"
399+ ">>> server.quit()"
320400
321401#: ../../tutorial/stdlib.rst:204
322402msgid "(Note that the second example needs a mailserver running on localhost.)"
@@ -355,6 +435,19 @@ msgid ""
355435">>> age.days\n"
356436"14368"
357437msgstr ""
438+ ">>> # 날짜는 쉽게 구성되고 포맷됩니다\n"
439+ ">>> from datetime import date\n"
440+ ">>> now = date.today()\n"
441+ ">>> now\n"
442+ "datetime.date(2003, 12, 2)\n"
443+ ">>> now.strftime(\" %m-%d-%y. %d %b %Y is a %A on the %d day of %B.\" )\n"
444+ "'12-02-03. 02 Dec 2003 is a Tuesday on the 02 day of December.'\n"
445+ "\n"
446+ ">>> # 날짜는 캘린더 산술을 지원합니다\n"
447+ ">>> birthday = date(1964, 7, 31)\n"
448+ ">>> age = now - birthday\n"
449+ ">>> age.days\n"
450+ "14368"
358451
359452#: ../../tutorial/stdlib.rst:236
360453msgid "Data Compression"
@@ -383,6 +476,17 @@ msgid ""
383476">>> zlib.crc32(s)\n"
384477"226805979"
385478msgstr ""
479+ ">>> import zlib\n"
480+ ">>> s = b'witch which has which witches wrist watch'\n"
481+ ">>> len(s)\n"
482+ "41\n"
483+ ">>> t = zlib.compress(s)\n"
484+ ">>> len(t)\n"
485+ "37\n"
486+ ">>> zlib.decompress(t)\n"
487+ "b'witch which has which witches wrist watch'\n"
488+ ">>> zlib.crc32(s)\n"
489+ "226805979"
386490
387491#: ../../tutorial/stdlib.rst:258
388492msgid "Performance Measurement"
@@ -415,6 +519,11 @@ msgid ""
415519">>> Timer('a,b = b,a', 'a=1; b=2').timeit()\n"
416520"0.54962537085770791"
417521msgstr ""
522+ ">>> from timeit import Timer\n"
523+ ">>> Timer('t=a; a=b; b=t', 'a=1; b=2').timeit()\n"
524+ "0.57535828626024577\n"
525+ ">>> Timer('a,b = b,a', 'a=1; b=2').timeit()\n"
526+ "0.54962537085770791"
418527
419528#: ../../tutorial/stdlib.rst:274
420529msgid ""
@@ -464,6 +573,16 @@ msgid ""
464573"import doctest\n"
465574"doctest.testmod() # automatically validate the embedded tests"
466575msgstr ""
576+ "def average(values):\n"
577+ " \"\"\" 숫자 목록의 산술 평균을 계산합니다.\n"
578+ "\n"
579+ " >>> print(average([20, 30, 70]))\n"
580+ " 40.0\n"
581+ " \"\"\" \n"
582+ " return sum(values) / len(values)\n"
583+ "\n"
584+ "import doctest\n"
585+ "doctest.testmod() # 내장된 테스트를 자동 검증합니다"
467586
468587#: ../../tutorial/stdlib.rst:306
469588msgid ""
@@ -490,6 +609,19 @@ msgid ""
490609"\n"
491610"unittest.main() # Calling from the command line invokes all tests"
492611msgstr ""
612+ "import unittest\n"
613+ "\n"
614+ "class TestStatisticalFunctions(unittest.TestCase):\n"
615+ "\n"
616+ " def test_average(self):\n"
617+ " self.assertEqual(average([20, 30, 70]), 40.0)\n"
618+ " self.assertEqual(round(average([1, 5, 7]), 1), 4.3)\n"
619+ " with self.assertRaises(ZeroDivisionError):\n"
620+ " average([])\n"
621+ " with self.assertRaises(TypeError):\n"
622+ " average(20, 30, 70)\n"
623+ "\n"
624+ "unittest.main() # 명령행에서 호출하면 모든 테스트를 수행합니다"
493625
494626#: ../../tutorial/stdlib.rst:328
495627msgid "Batteries Included"
@@ -505,7 +637,6 @@ msgstr ""
505637"예를 들어:"
506638
507639#: ../../tutorial/stdlib.rst:333
508- #, fuzzy
509640msgid ""
510641"The :mod:`xmlrpc.client` and :mod:`xmlrpc.server` modules make "
511642"implementing remote procedure calls into an almost trivial task. Despite"
@@ -562,9 +693,9 @@ msgstr ""
562693
563694#: ../../tutorial/stdlib.rst:27
564695msgid "built-in function"
565- msgstr ""
696+ msgstr "내장 함수 "
566697
567698#: ../../tutorial/stdlib.rst:27
568699msgid "help"
569- msgstr ""
700+ msgstr "도움말 "
570701
0 commit comments