您當前的位置:首頁 > 體育

請問一下我的這段程式碼為什麼第一次輸入E時什麼都沒有輸出,第二次才輸出了正確的答案?

作者:由 陳柚子 發表于 體育時間:2022-03-23

請問一下我的這段程式碼為什麼第一次輸入E時什麼都沒有輸出,第二次才輸出了正確的答案?彼得大碗2022-03-24 18:27:09

因為 a =

input

(“請輸入索引名(quit退出):”)。lower() 使用了兩次,所以出現兩次 E

簡單改了一下,不知道能不能透過:(呵呵)

import

pandas

as

pd

s

=

pd

Series

list

‘堅實的基礎乃致勝之法寶’

),

index

=

list

‘abcdefghijk’

))

print

‘目前 Series:

\n

s

sep

=

‘’

while

True

a

=

input

“請輸入索引名(quit退出):”

lower

()

a

=

a

strip

()

# 去掉首尾空格

if

a

==

‘quit’

break

if

a

not

in

‘abcdefghijk’

print

“索引名錯誤,請重新輸入!”

continue

else

b

=

s

index

tolist

()

index

a

if

1

<=

b

<=

9

print

s

b

-

1

b

+

2

])

if

b

==

0

print

s

b

b

+

2

])

if

b

==

10

print

s

b

-

1

b

+

1

])

請問一下我的這段程式碼為什麼第一次輸入E時什麼都沒有輸出,第二次才輸出了正確的答案?

標簽: print  quit  index  索引  input