有人可以告诉为什么在begin
的条件之后没有为if begin:
分配值而只是以冒号结束?我可以知道它是什么意思吗?
if begin:
begin = int(begin)
end = int(raw_input("End:"))
print "word[", begin,":",end,"] ",
print word[begin:end]
raw_input("\n\nPress the Enter Key to exit.")
谢谢!
答案 0 :(得分:0)
我尝试了下面的剪辑并且有效。
word = "PythonWizard"
print word
begin = int(raw_input("Begin:"))
if begin:
begin = int(begin)
end = int(raw_input("End:"))
print "word[", begin,":",end,"] ",
print word[begin:end]
raw_input("\n\nPress the Enter Key to exit.")