python 輸入和列印輸出

2021-10-12 21:20:09 字數 767 閱讀 2474

##方式一:直接等待從鍵盤上輸入資訊,然後回車

name=

input()

##方式二:先輸出一些提示資訊

name=

input

(『please enter your name:』)

# 方式一:單字串

print

('hello, world'

)# 方式二:多字串,遇到逗號「,」會輸出乙個空格

print

('the quick brown fox'

,'jumps over'

,'the lazy dog'

)# 方式三:表示式

print

('100 + 200 ='

,100

+200

)# 方式四:變數

print

("a=%d, b=%d"

, a, b)

python 中通過使用 sys 的 sys.ar** 來獲取命令列引數:

#!/usr/bin/python

# -*- coding: utf-8 -*-

import sys

print

'引數個數為:'

,len

(sys.ar**)

,'個引數。'

print

'引數列表:'

,str

(sys.ar**)

Python之列印輸出稜形

列印輸出稜形 這裡是一段防爬蟲文字,請讀者忽略。本文原創首發於csdn,作者idys 部落格首頁 稜形上下三角形對稱,所以上面列印出朝上的三角形,下面列印出朝下的三角形 三角形由和 組成 def demo04 i 1 length int input 請輸入長度 while i length pri...

python3 print 列印輸出

1 列印字串 print hello world 輸出結果 hello world 2 列印中文字串 print 世界,你好!輸出結果 世界,你好!3 列印變數 a 10 print a 輸出結果 10 4 列印自定義函式值 def add2 x,y return x 2,y 2 print add...

列印輸出部門結構

列印出部門結構 如下 連線資料庫,並且獲取資料。link mysqli connect localhost mysqli select db link,test sql select from print where 1 retval mysqli query link,sql array arra...