我正在尝试将我选择的图像转换为base64然后上传到服务器但是当我进入图像选择器时我似乎得到一个奇怪的错误我得到错误创建一个未知类型的图像格式是一个错误
def PinGuess(pin,nums):
global Found,Invalid
while not Found:
Numbers = xrange(nums)
current_pin = int(choice(Numbers))
if current_pin not in Invalid:
call(['clear'])
print 'Trying: {}'.format(current_pin)
if current_pin == pin: Found = True
else: Invalid.append(current_pin)
print len(Invalid)
if __name__ == '__main__':
Found = False
Invalid = []
Pin = 123
for i in range(1):
Process(target=PinGuess, args=(Pin,300)).start()
# - Output 1
Trying: 123
104
real 0m0.904s
user 0m0.316s
sys 0m0.440s
# - Code 2
#!/usr/bin/env python
#
#
#
from multiprocessing import Process
from random import choice
from subprocess import *
from time import sleep
def PinGuess(pin,nums):
global Found,Invalid
while not Found:
Numbers = xrange(nums)
current_pin = int(choice(Numbers))
if current_pin not in Invalid:
call(['clear'])
print 'Trying: {}'.format(current_pin)
if current_pin == pin: Found = True
else: Invalid.append(current_pin)
print len(Invalid)
if __name__ == '__main__':
Found = False
Invalid = []
Pin = 123
for i in range(10):
Process(target=PinGuess, args=(Pin,300)).start()
# - Output 2
Trying: 123
296
real 0m10.530s
user 0m3.652s
sys 0m8.328s
答案 0 :(得分:0)
您是否尝试在选择器委托功能中将AnyObject
更改为Any
?
swift3的正确语法是:
func imagePickerController(_ picker: UIImagePickerController,
didFinishPickingMediaWithInfo info: [String : Any]) {
}
答案 1 :(得分:0)
试试这个:
if let chosenImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
...
}
答案 2 :(得分:0)
我在选择器中点击图像时在模拟器中收到错误,但是在用户通过点击“选择”按钮确认选择之前。也就是说,该应用程序在所有外观上都可以正常工作。
由于用户也可以点击“取消”但保留在选择器中(因此在控制返回应用程序之前,点击另一个图像会在控制台上出现相同的错误),我怀疑问题出在Apple的代码中(至少在模拟器中运行时。)