|
8 | 8 | # tomo, 2023
|
9 | 9 | # Nozomu Kaneko <nozom.kaneko@gmail.com>, 2023
|
10 | 10 | # Takanori Suzuki <takanori@takanory.net>, 2024
|
| 11 | +# righteous, 2025 |
11 | 12 | #
|
12 | 13 | #,fuzzy
|
13 | 14 | msgid ""
|
14 | 15 | msgstr ""
|
15 | 16 | "Project-Id-Version: Python 3.13\n"
|
16 | 17 | "Report-Msgid-Bugs-To: \n"
|
17 |
| -"POT-Creation-Date: 2025-04-11 14:19+0000\n" |
| 18 | +"POT-Creation-Date: 2025-04-25 14:19+0000\n" |
18 | 19 | "PO-Revision-Date: 2021-06-28 01:50+0000\n"
|
19 |
| -"Last-Translator: Takanori Suzuki <takanori@takanory.net>, 2024\n" |
| 20 | +"Last-Translator: righteous, 2025\n" |
20 | 21 | "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/"
|
21 | 22 | "ja/)\n"
|
22 | 23 | "MIME-Version: 1.0\n"
|
@@ -50,6 +51,12 @@ msgid ""
|
50 | 51 | ">>> os.system('mkdir today') # Run the command mkdir in the system shell\n"
|
51 | 52 | "0"
|
52 | 53 | msgstr""
|
| 54 | +">>> import os\n" |
| 55 | +">>> os.getcwd() # 現在のワーキングディレクトリ\n" |
| 56 | +"C:\\\\Python313 を返す\n" |
| 57 | +">>> os.chdir('/server/accesslogs') # ワーキングディレクトリを変更\n" |
| 58 | +">>> os.system('mkdir today') # システムのシェルで mkdir コマンドを実行\n" |
| 59 | +"0" |
53 | 60 |
|
54 | 61 | #:../../tutorial/stdlib.rst:23
|
55 | 62 | msgid""
|
@@ -77,6 +84,11 @@ msgid ""
|
77 | 84 | ">>> help(os)\n"
|
78 | 85 | "<returns an extensive manual page created from the module's docstrings>"
|
79 | 86 | msgstr""
|
| 87 | +">>> import os\n" |
| 88 | +">>> dir(os)\n" |
| 89 | +"<OSモジュールの関数すべてのリストを返す>\n" |
| 90 | +">>> help(os)\n" |
| 91 | +"<モジュールの docstring から生成された詳細なマニュアルを返す>" |
80 | 92 |
|
81 | 93 | #:../../tutorial/stdlib.rst:38
|
82 | 94 | msgid""
|
@@ -280,6 +292,15 @@ msgid ""
|
280 | 292 | ">>> random.randrange(6) # random integer chosen from range(6)\n"
|
281 | 293 | "4"
|
282 | 294 | msgstr""
|
| 295 | +">>> import random\n" |
| 296 | +">>> random.choice(['apple', 'pear', 'banana'])\n" |
| 297 | +"'apple'\n" |
| 298 | +">>> random.sample(range(100), 10) # 重複なしでサンプリング\n" |
| 299 | +"[30, 83, 16, 4, 8, 81, 41, 50, 18, 33]\n" |
| 300 | +">>> random.random() # [0.0, 1.0) の区間内のランダムな float\n" |
| 301 | +"0.17970987693706186\n" |
| 302 | +">>> random.randrange(6) # range(6) からランダムに選ばれた integer\n" |
| 303 | +"4" |
283 | 304 |
|
284 | 305 | #:../../tutorial/stdlib.rst:161
|
285 | 306 | msgid""
|
@@ -346,6 +367,25 @@ msgid ""
|
346 | 367 | "... \"\"\")\n"
|
347 | 368 | ">>> server.quit()"
|
348 | 369 | msgstr""
|
| 370 | +">>> from urllib.request import urlopen\n" |
| 371 | +">>> with urlopen('http://worldtimeapi.org/api/timezone/etc/UTC.txt') as " |
| 372 | +"response:\n" |
| 373 | +"... for line in response:\n" |
| 374 | +"... line = line.decode() # str を bytes に変換\n" |
| 375 | +"... if line.startswith('datetime'):\n" |
| 376 | +"... print(line.rstrip()) # 末尾の改行を削除\n" |
| 377 | +"...\n" |
| 378 | +"datetime: 2022-01-01T01:36:47.689215+00:00\n" |
| 379 | +"\n" |
| 380 | +">>> import smtplib\n" |
| 381 | +">>> server = smtplib.SMTP('localhost')\n" |
| 382 | +">>> server.sendmail('soothsayer@example.org', 'jcaesar@example.org',\n" |
| 383 | +"... \"\"\"To: jcaesar@example.org\n" |
| 384 | +"... From: soothsayer@example.org\n" |
| 385 | +"...\n" |
| 386 | +"... Beware the Ides of March.\n" |
| 387 | +"... \"\"\")\n" |
| 388 | +">>> server.quit()" |
349 | 389 |
|
350 | 390 | #:../../tutorial/stdlib.rst:204
|
351 | 391 | msgid"(Note that the second example needs a mailserver running on localhost.)"
|
@@ -387,6 +427,19 @@ msgid ""
|
387 | 427 | ">>> age.days\n"
|
388 | 428 | "14368"
|
389 | 429 | msgstr""
|
| 430 | +">>> # 日付 (date) は容易に作成・フォーマットが可能\n" |
| 431 | +">>> from datetime import date\n" |
| 432 | +">>> now = date.today()\n" |
| 433 | +">>> now\n" |
| 434 | +"datetime.date(2003, 12, 2)\n" |
| 435 | +">>> now.strftime(\"%m-%d-%y. %d %b %Y is a %A on the %d day of %B.\")\n" |
| 436 | +"'12-02-03. 02 Dec 2003 is a Tuesday on the 02 day of December.'\n" |
| 437 | +"\n" |
| 438 | +">>> # date で日付の演算が可能\n" |
| 439 | +">>> birthday = date(1964, 7, 31)\n" |
| 440 | +">>> age = now - birthday\n" |
| 441 | +">>> age.days\n" |
| 442 | +"14368" |
390 | 443 |
|
391 | 444 | #:../../tutorial/stdlib.rst:236
|
392 | 445 | msgid"Data Compression"
|
@@ -502,6 +555,16 @@ msgid ""
|
502 | 555 | "import doctest\n"
|
503 | 556 | "doctest.testmod() # automatically validate the embedded tests"
|
504 | 557 | msgstr""
|
| 558 | +"def average(values):\n" |
| 559 | +" \"\"\"数値のリストの算術平均を計算する。\n" |
| 560 | +"\n" |
| 561 | +" >>> print(average([20, 30, 70]))\n" |
| 562 | +" 40.0\n" |
| 563 | +" \"\"\"\n" |
| 564 | +" return sum(values) / len(values)\n" |
| 565 | +"\n" |
| 566 | +"import doctest\n" |
| 567 | +"doctest.testmod() # docstring に埋め込まれたテストを自動的に評価" |
505 | 568 |
|
506 | 569 | #:../../tutorial/stdlib.rst:306
|
507 | 570 | msgid""
|
@@ -529,6 +592,19 @@ msgid ""
|
529 | 592 | "\n"
|
530 | 593 | "unittest.main() # Calling from the command line invokes all tests"
|
531 | 594 | msgstr""
|
| 595 | +"import unittest\n" |
| 596 | +"\n" |
| 597 | +"class TestStatisticalFunctions(unittest.TestCase):\n" |
| 598 | +"\n" |
| 599 | +" def test_average(self):\n" |
| 600 | +" self.assertEqual(average([20, 30, 70]), 40.0)\n" |
| 601 | +" self.assertEqual(round(average([1, 5, 7]), 1), 4.3)\n" |
| 602 | +" with self.assertRaises(ZeroDivisionError):\n" |
| 603 | +" average([])\n" |
| 604 | +" with self.assertRaises(TypeError):\n" |
| 605 | +" average(20, 30, 70)\n" |
| 606 | +"\n" |
| 607 | +"unittest.main() # コマンドラインからこれを呼び出すとテストがすべて実行される" |
532 | 608 |
|
533 | 609 | #:../../tutorial/stdlib.rst:328
|
534 | 610 | msgid"Batteries Included"
|
|
0 commit comments