表示させるpyファイル ==共通==
ファイル名: test.py
print("Content-type: text/html\n")
print("<html><body>Python is Fabulous !</body></html>")
print("<html><body>Python is Fabulous !</body></html>")
A.上手く表示される場合
(1). Directory構成
---test/
|
|---cgi-bin/
|
|--- test.py
(a) cmd コマンド:
test directoryにて
test>python -m http.server 8000 --cgi
localhost:8000/cgi-bin/test.py
4.上手く表示できない
(1). Directory構成
---test/
|--test.py
|---cgi-bin/
|
(2) cmd コマンド:
test directoryにて
test>python -m http.server 8000
localhost:8000/test.py
技法1:
answer1 = 50
answer2 = 100
print('答え1:{0}, 答え2:{1}'.format(answer1, answer2))
技法2:
answer = 50
print('答え:%d' % answer)
これらを使って、こんな愚直な書き方が出来る。
ファイル名:test.py
list = ['Tuna','Bacon','Burger','Tacos']
love = list[2]
hate = list[0]
print("Content-type: text/html\n")
print("<html><body>Python is Fabulous !<br/>")
print("Food I Love: {0}, Food I hate:{1}".format(love,hate))
print("</body></html>")
Output)
Python is Fabulous !
Food I Love: Burger, Food I hate:Tuna
◆文字型、数値型混在表記
print("Content-type: text/html\n")
print("""
<html><body>
This is web site made by Python!
<p>This is easy one!</p> """)
name = "ALice"
age = 25
print("name is " + name+"<br/>")
print("age is " + age+"<br/>") # This doesn't work
print("age is " + str(age)+"<br/>")
print("name is " + name+" age is"+str(age)+"years old"+"<br/>")
print("<hr>")
print(f' name is {name}, age is {age} ')
print("""
</body></html>
""")
Python 3 コマンドライン 一覧 参照
print("""
<html><body>
This is web site made by Python!
<p>This is easy one!</p> """)
name = "ALice"
age = 25
print("name is " + name+"<br/>")
print("age is " + age+"<br/>") # This doesn't work
print("age is " + str(age)+"<br/>")
print("name is " + name+" age is"+str(age)+"years old"+"<br/>")
print("<hr>")
print(f' name is {name}, age is {age} ')
print("""
</body></html>
""")
Python 3 コマンドライン 一覧 参照
py.ファイル
list =['Tuna', 'Bacon', 'Softcream', 'Hot Dog']
html_output += f '<p> There are {len(list)} items in the list that I like.</p> '
0 件のコメント:
コメントを投稿