def main():
name=input("Enter your name: ") #just write our name nothin important
print (name, "is Swag")
value1=int(input("enter a value: ")) #takes in the number without doubt
print(value1)
value2=float(int("Enter a fraction: ")) #heres our problem but what?
print(value2)
main()
只是一個簡單的程序,我玩用左右,但它顯示了這個錯誤,因爲你都可能想知道:如何採取一個整數,並使用一小部分就可以了
我寫例如1/2一個這表明,除非你使用eval
(這是不安全的,所以我不能建議)
Traceback (most recent call last):
File "C:\Users\waliu\Documents\Waliur Uni stuff\Information
systems\Python Programs\Samples\apparently fractions.py", line 8, in
<module>
main()
File "C:\Users\waliu\Documents\Waliur Uni stuff\Information
systems\Python Programs\Samples\apparently fractions.py", line 6, in main
value2=float(input("Enter a fraction: "))
ValueError: could not convert string to float: '1/2'
Python做,如果你問好聽,像PM2Ring評估分數... –
忘了那一個。好。我開始認爲這可能是重複的。它是,在某種程度上:https://stackoverflow.com/questions/1806278/convert-fraction-to-float –
謝謝你的幫助 – PL8YR