LoginSignup
1
0

More than 5 years have passed since last update.

Hello, World 書けます

Last updated at Posted at 2017-11-07

Hello, World を Python でかけると転職先が見つかると聞いて!! (違

MyHelloWorld.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sqlite3


def main():
    with sqlite3.connect(':memory:') as conn:
        strSQL = '''
SELECT 'Hello, World!'
'''
        lines = conn.execute(strSQL).fetchall()
        for line in lines:
            print(line[0])


if __name__ == '__main__':
    main()

2018/12/2 try-finally を使っていたのを with で置き換え

2019/01/25 ちょい修正。

MyHelloWorld.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sqlite3


def main():
    with sqlite3.connect(':memory:') as conn:
        strSQL = '''
SELECT 'Hello, World!'
'''
        print(conn.execute(strSQL).fetchall()[0][0])


if __name__ == '__main__':
    main()
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0