{"id":4833,"date":"2021-05-26T17:12:37","date_gmt":"2021-05-26T08:12:37","guid":{"rendered":"https:\/\/www.sambuichi.jp\/?p=4833"},"modified":"2021-05-27T18:45:43","modified_gmt":"2021-05-27T09:45:43","slug":"visual-studio-code%e3%81%a7%e3%81%aepython%e9%96%8b%e7%99%ba%e7%92%b0%e5%a2%83","status":"publish","type":"post","link":"https:\/\/www.sambuichi.jp\/?p=4833","title":{"rendered":"Visual Studio Code\u3067\u306epython\u958b\u767a\u74b0\u5883"},"content":{"rendered":"<p>Views: 71<\/p><h1>macOS Catalina\u3067VS Code\u3092\u4f7f\u7528\u3057\u3066Python\u958b\u767a<\/h2>\n<p>GitHub\u74b0\u5883\u306e\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u8ffd\u52a0\u3057\u305f\u30ef\u30fc\u30af\u30b9\u30da\u30fc\u30b9\u3092\u65b0\u898f\u4f5c\u6210\u3002GitHub\u74b0\u5883\u306e\u4e0b\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u958b\u767a\u3057\u3066\u3044\u305f\u304c\u3001VS Code\u306e\u89e3\u91c8\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u9020\u3068Python\u306e\u8a8d\u8b58\u3059\u308b\u76f8\u5bfe\u30d1\u30b9\u304c\u305a\u308c\u3066\u3044\u308b\u306e\u3067\u3001Python\u958b\u767a\u7528\u306e\u30ef\u30fc\u30af\u30b9\u30da\u30fc\u30b9\u3092\u65b0\u898f\u306b\u5b9a\u7fa9\u3057\u305f\u3002<br \/>\n\u30c7\u30d0\u30c3\u30b0\u74b0\u5883\u306f\u3001\u6a19\u6e96\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u3082\u306e\u3092\u4f7f\u7528\u3057\u305f\u3002<br \/>\n\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u5b9f\u884c\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u30c7\u30d0\u30c3\u30b0\u3059\u308b\u969b\u306b\u3001 .vscode\/launch.json\u306b&#8221;args&#8221;\u306e\u6307\u5b9a\u3092\u8ffd\u52a0\u3057\u305f\u3002<br \/>\n\u30c7\u30d0\u30c3\u30b0\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/code.visualstudio.com\/docs\/editor\/debugging\">VS Code Debugging<\/a>\u53ca\u3073<a href=\"https:\/\/code.visualstudio.com\/docs\/editor\/debugging#_launch-configurations\">VS Code launch configurations<\/a>\u53c2\u7167<\/p>\n<pre class=\"lang:js decode:true \" >{\r\n  \/\/ IntelliSense \u3092\u4f7f\u7528\u3057\u3066\u5229\u7528\u53ef\u80fd\u306a\u5c5e\u6027\u3092\u5b66\u3079\u307e\u3059\u3002\r\n  \/\/ \u65e2\u5b58\u306e\u5c5e\u6027\u306e\u8aac\u660e\u3092\u30db\u30d0\u30fc\u3057\u3066\u8868\u793a\u3057\u307e\u3059\u3002\r\n  \/\/ \u8a73\u7d30\u60c5\u5831\u306f\u6b21\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044: https:\/\/go.microsoft.com\/fwlink\/?linkid=830387\r\n  \"version\": \"0.2.0\",\r\n  \"configurations\": [\r\n    {\r\n      \"name\": \"Python: Current File\",\r\n      \"type\": \"python\",\r\n      \"request\": \"launch\",\r\n      \"program\": \"${file}\",\r\n      \"console\": \"integratedTerminal\",\r\n      \"args\": [\"data\/in\/ubl-tc434-example8.xml\", \"data\/out\/ubl-tc434-example8.tsv\"] \/\/ invoice2tsv\r\n      \/\/ \"args\": [\"data\/out\/ubl-tc434-example6.tsv\", \"data\/out\/ubl-tc434-example6.xml\"] \/\/ genInvoice\r\n    }\r\n  ]\r\n}<\/pre>\n<p>\u3053\u306e\u6307\u5b9a\u3067\u3001[\u5b9f\u884c]\u30e1\u30cb\u30e5\u30fc\u304b\u3089\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u5f15\u6570\u3092\u6307\u5b9a\u3057\u305f\u30c7\u30d0\u30c3\u30b0\u304c\u53ef\u80fd\u3068\u306a\u3063\u305f\u3002<br \/>\n<a  href=\"https:\/\/www.sambuichi.jp\/wp-content\/uploads\/2021\/05\/a398b2a30cdda09d6faf5a98dd41a3e7.png\" data-rel=\"lightbox-gallery-0\" data-rl_title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2021-05-26 17.14.27\" data-rl_caption=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2021-05-26 17.14.27\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.sambuichi.jp\/wp-content\/uploads\/2021\/05\/a398b2a30cdda09d6faf5a98dd41a3e7-1024x640.png\" alt=\"\" width=\"1024\" height=\"640\" class=\"alignnone size-large wp-image-4836\" srcset=\"https:\/\/www.sambuichi.jp\/wp-content\/uploads\/2021\/05\/a398b2a30cdda09d6faf5a98dd41a3e7-1024x640.png 1024w, https:\/\/www.sambuichi.jp\/wp-content\/uploads\/2021\/05\/a398b2a30cdda09d6faf5a98dd41a3e7-300x188.png 300w, https:\/\/www.sambuichi.jp\/wp-content\/uploads\/2021\/05\/a398b2a30cdda09d6faf5a98dd41a3e7-768x480.png 768w, https:\/\/www.sambuichi.jp\/wp-content\/uploads\/2021\/05\/a398b2a30cdda09d6faf5a98dd41a3e7-1536x960.png 1536w, https:\/\/www.sambuichi.jp\/wp-content\/uploads\/2021\/05\/a398b2a30cdda09d6faf5a98dd41a3e7-2048x1280.png 2048w, https:\/\/www.sambuichi.jp\/wp-content\/uploads\/2021\/05\/a398b2a30cdda09d6faf5a98dd41a3e7-110x70.png 110w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<h2>\u5f15\u6570\u304b\u3089\u5165\u51fa\u529b\u306e\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>file_path\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u3092\u53d6\u5f97\u3057\u3066\u3001os.path.isfile()\u3067\u5165\u529b\u30d5\u30a1\u30a4\u30eb\u306e\u5b58\u5728\u30c1\u30a7\u30c3\u30af\u3057\u3066\u3044\u308b\u3002\u30d5\u30a1\u30a4\u30eb\u304c\u306a\u3051\u308c\u3070\u3001 sys.exit()\u3067\u51e6\u7406\u3092\u4e2d\u65ad\u3002<\/p>\n<pre class=\"height-set:true width-set:true lang:python decode:true \" >  # Create the parser\r\nimport sys \r\nimport os\r\nimport argparse\r\n\r\ndef file_path(pathname):\r\n  if \"\/\" == pathname[0:1]:\r\n    return pathname\r\n  else:\r\n    dir = os.path.dirname(__file__)\r\n    new_path = os.path.join(dir, pathname)\r\n    return new_path\r\n\r\nmy_parser = argparse.ArgumentParser(prog='genInvoice',\r\n                                      usage='%(prog)s [options] infile outfile',\r\n                                      description='\u30d5\u30a1\u30a4\u30eb\u5909\u63db')\r\n  # Add the arguments\r\n  my_parser.add_argument('inFile',\r\n                        metavar='infile',\r\n                        type=str,\r\n                        help='\u5165\u529b\u30d5\u30a1\u30a4\u30eb')\r\n  my_parser.add_argument('outFile',\r\n                        metavar='outfile',\r\n                        type=str,\r\n                        help='\u51fa\u529b\u30d5\u30a1\u30a4\u30eb')\r\n\r\n  args = my_parser.parse_args()\r\n  in_file = file_path(args.inFile)\r\n  out_file = file_path(args.outFile)\r\n  # Check if infile exists\r\n  if not os.path.isfile(in_file):\r\n      print('\u5165\u529b\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308a\u307e\u305b\u3093')\r\n      sys.exit()<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Views: 71macOS Catalina\u3067VS Code\u3092\u4f7f\u7528\u3057\u3066Python\u958b\u767a GitHub\u74b0\u5883\u306e\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u8ffd\u52a0\u3057\u305f\u30ef\u30fc\u30af\u30b9\u30da\u30fc\u30b9\u3092\u65b0\u898f\u4f5c\u6210\u3002GitHub\u74b0\u5883\u306e\u4e0b\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u958b\u767a\u3057\u3066\u3044\u305f\u304c\u3001VS C [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":4841,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[50],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/posts\/4833"}],"collection":[{"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4833"}],"version-history":[{"count":10,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/posts\/4833\/revisions"}],"predecessor-version":[{"id":4858,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/posts\/4833\/revisions\/4858"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/media\/4841"}],"wp:attachment":[{"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}