我想从文件管理器中选择一个文件,我必须将其转换为byte []并通过Ksoap2 webservice发送。但不幸的是,在将文件转换为byte []时发生错误。这是我的代码。
#this if for a combat mechanism
import random
def end(enemy_health,your_health):
if your_health > 0:
print(" ")
print("You slay the Ork")
else:
print(" ")
print("You were slain...")
def your_first():
enemy_health = 20
your_health =20
while your_health > 0 and enemy_health > 0:
your_damage = random.choice(range(7,13))
enemy_health -= your_damage
if enemy_health <= 0:
enemy_health = 0
print(" ")
print("You dealt " + str(your_damage) + " damage!")
print("Enemy's health:" + str(enemy_health))
end(enemy_health,your_health)
else:
print(" ")
print("You dealt " + str(your_damage) + " damage!")
print("Enemy's health:" + str(enemy_health))
enemy_damage = random.choice(range(9, 21))
your_health -= enemy_damage
if your_health <= 0:
your_health = 0
print(" ")
print("Ork dealt " + str(enemy_damage) + " damage!")
print("Your health:" + str(your_health))
end(enemy_health,your_health)
else:
print(" ")
print("Ork dealt " + str(enemy_damage) + " damage!")
print("Your health:" + str(your_health))
def enemy_first():
enemy_health = 20
your_health =20
while your_health > 0 and enemy_health > 0:
enemy_damage = random.choice(range(9, 21))
your_health -= enemy_damage
if your_health <= 0:
your_health = 0
print(" ")
print("Ork dealt " + str(enemy_damage) + " damage!")
print("Your health:" + str(your_health))
end(enemy_health,your_health)
else:
print(" ")
print("Ork dealt " + str(enemy_damage) + " damage!")
print("Your health:" + str(your_health))
your_damage = random.choice(range(7,13))
enemy_health -= your_damage
if enemy_health <= 0:
print(" ")
print("You dealt " + str(your_damage) + " damage!")
print("Enemy's health:" + str(enemy_health))
end(enemy_health,your_health)
else:
print(" ")
print("You dealt " + str(your_damage) + " damage!")
print("Enemy's health:" + str(enemy_health))
print("(+)~~~~~~~~~~~~~~~(+)")
print(" | Damage: | ")
print(" | 7-12 | ")
print(" | Speed: | ")
print(" | 6/10 | ")
print(" | Critical Chance:| ")
print(" | 64% | ")
print("(+)~~~~~~~~~~~~~~~(+)")
print(" ")
print("You encountered an Ork")
enemy = "Ork"
print(" ")
print("(+)~~~~~~~~~~~~~~~(+)")
print(" |Ork | Health: 20| ")
print(" |-----------------| ")
print(" |Damage: 9-20| ")
print(" |-----------------| ")
print(" |Speed: 2/10| ")
print(" |-----------------| ")
print(" |Crit Chance: 13%| ")
print("(+)~~~~~~~~~~~~~~~(+)")
print("You engage the Ork in a battle!")
your_crit = (1, 65)
enemy_crits = (1, 13)
your_speed = 6
ork_speed = 2
if ork_speed >= your_speed:
print("The " + enemy + " is faster, it attacks first!")
enemy_first()
else:
print("You're faster and get to attack first!")
your_first()
这是我的OnActivityResult()方法,在这里我收到了我使用Intent.createChooser enter image description here从我的设备中选择的文件 这里参考的是我的logcat。请解决此错误。