方法如下:
首先,要在iosApp工程中安装python解释器,比如pybee的python-ios-support,编译时target选择iphoneos.armv7或者arm64。
然后,用pip install安装rubicon-objc搭建python和objc的桥梁。
最后,用python写ios语法,开发app即可。
请采纳,谢谢
当我们爬取一些页面的中文信息时,会出现如下情况:
爬取的中文编码格式不是UTF-8,无法正常显示,查看编码格式:
先编码
encode(编码):按照某种规则将“文本”转换为“字节流”,unicode转化为str
decode(解码):将“字节流”按照某种规则转换成“文本”,str转化为unicode
s.decode(' '):运行会出错。因为python 3中的str类型对象有点像Python 2中的unicode, 而decode是将str转为unicode编码,所以str仅有一个encode方法,调用这个方法后将产生一个编码后的byte类型的字符。
AttributeError: 'str' object has no attribute 'decode'
AttributeError: 'bytes' object has no attribute 'encode'
比如str是ISO-8859-2格式的字符串,你需要先解码:str = str.decode("ISO-8859-2"),这样返回的就是unicode的str,
然后再使用个utf8编码:str = str.encode("utf-8"),这样就是utf8的了。
也就是str=str.decode("ISO-8859-2").encode("utf-8")
如果解决了您的问题请采纳!
如果未解决请继续追问!