小编JAM*_*JAM的帖子

类型'ViewController'不符合协议

我正在学习Swift并学习一些教程.我一直收到错误:输入

'ViewController'不符合协议'UITableViewDataSource'

import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    var GetAllDataTest  = NSMutableArray()
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func viewWillAppear(_ animated: Bool) {

        GetAllDataTest = FMDBDatabaseModel.getInstance().GetAllData()
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "TestTableViewCell") as! TestTableViewCell
        //cell.editData = self
        cell.tag = indexPath.row
        var l = Tbl_Test()
        l = GetAllDataTest.object(at: indexPath.row) as! Tbl_Test

        cell.lblName.text! = l.Name
        cell.lblMobileNo.text! …
Run Code Online (Sandbox Code Playgroud)

xcode viewcontroller ios swift

0
推荐指数
1
解决办法
629
查看次数

在Python中剥离列表

我在python中有一个列表,它是由许多函数产生的。它是这样产生的:

['01', '1.0', '[0.2]']
Run Code Online (Sandbox Code Playgroud)

生成后,我想剥离所有不必要的字符。

理想输出:

['01', '1.0', '0.2']
Run Code Online (Sandbox Code Playgroud)

我基本上需要从列表中的最后一个字符串中删除[和]。

更新:

list_test = ['01', '1.0', '[0.2]']
[i.strip('[]') if type(i) == str else str(i) for i in list_test]
print(list_test)
Run Code Online (Sandbox Code Playgroud)

不管有没有产生相同的结果,这都不起作用:

['01', '1.0', '[0.2]']
Run Code Online (Sandbox Code Playgroud)

所需的结果是:

['01', '1.0', '0.2']
Run Code Online (Sandbox Code Playgroud)

提供的解决方案:

l = ['01', '1.0', '[0.2]']
[i.strip('[0.2]') if type(i) == str else str(i) for i in l]
print(l)
Run Code Online (Sandbox Code Playgroud)

输出:

['01', '1.0', '0.2']

Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud)

python list python-3.x

-3
推荐指数
1
解决办法
7599
查看次数

标签 统计

ios ×1

list ×1

python ×1

python-3.x ×1

swift ×1

viewcontroller ×1

xcode ×1