返回list.append()在递归函数中引发“ TypeError:不支持的操作数类型”

时间:2019-04-07 09:17:33

标签: python python-3.x

我尝试编写一个递归函数以返回最长的递增子序列,但是发生错误,提示“ void main() => runApp(MaterialApp(home: Scaffold(body: HomePage()))); class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin { AnimationController _controller; bool _isPlaying = true; @override void initState() { super.initState(); _controller = AnimationController( vsync: this, lowerBound: 0.3, duration: Duration(seconds: 3), )..repeat(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text("Animation")), body: Stack( alignment: Alignment.center, children: <Widget>[ _buildCircularContainer(200), _buildCircularContainer(250), _buildCircularContainer(300), Align(child: CircleAvatar(backgroundImage: AssetImage("assets/images/profile.png"), radius: 72)), Align( alignment: Alignment(0, 0.5), child: RaisedButton( child: Text(_isPlaying ? "STOP" : "START"), onPressed: () { if (_isPlaying) _controller.reset(); else _controller.repeat(); setState(() => _isPlaying = !_isPlaying); }, ), ), ], ), ); } Widget _buildCircularContainer(double radius) { return AnimatedBuilder( animation: CurvedAnimation(parent: _controller, curve: Curves.fastLinearToSlowEaseIn), builder: (context, child) { return Container( width: _controller.value * radius, height: _controller.value * radius, decoration: BoxDecoration(color: Colors.black54.withOpacity(1 - _controller.value), shape: BoxShape.circle), ); }, ); } }

TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'

1 个答案:

答案 0 :(得分:2)

openssl pkcs12 -in "Certificates.p12" -nocerts -out key.pem 是就地操作。例如,

ssl.SSLError: [SSL] PEM lib (_ssl.c:3507)

list.append返回l = [1, 2, 3] result = l.append(4) print(result) # None print(l) # [1, 2, 3, 4] ,就地修改append。这意味着函数中的None将返回l,并且两个递归调用将导致return result.append(cur_seq),从而为您提供None

解决方法是先添加 ,然后返回

None + None